Skip to content

Commit

Permalink
selected did tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maycon-mello committed Aug 16, 2023
1 parent d786cbf commit fc111ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
9 changes: 9 additions & 0 deletions packages/core/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ module.exports = {
'@digitalbazaar/x25519-key-agreement-key-2020/lib/X25519KeyAgreementKey2020',
'@digitalbazaar/ed25519-verification-key-2020':
'@digitalbazaar/ed25519-verification-key-2020/lib/Ed25519VerificationKey2020',
'@digitalbazaar/ed25519-verification-key-2018':
'@digitalbazaar/ed25519-verification-key-2018/src/Ed25519VerificationKey2018',
'@digitalbazaar/minimal-cipher': '@digitalbazaar/minimal-cipher/Cipher',
'@digitalbazaar/did-method-key': '@digitalbazaar/did-method-key/lib/main',
'@docknetwork/wallet-sdk-wasm/lib/(.*)':
'@docknetwork/wallet-sdk-wasm/src/$1',
'@docknetwork/wallet-sdk-data-store/lib/(.*)':
'@docknetwork/wallet-sdk-data-store/src/$1',
'@docknetwork/wallet-sdk-data-store/lib':
'@docknetwork/wallet-sdk-data-store/src',
},
transformIgnorePatterns: [
'/node_modules/(?!@polkadot|@babel|@docknetwork|@digitalbazaar)',
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/verification-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Verification provider', () => {
const currentDID = await didProvider.getAll();

expect(controller.getSelectedDID()).toBe(currentDID[0].id);
expect(controller.getSelectedAttributes()).toBe([]);
expect(controller.getSelectedAttributes()).toEqual([]);
expect(controller.getTemplateJSON()).toEqual(verificationTemplateJSON);
expect(controller.getFilteredCredentials()).toEqual([
customerCredentialJSON,
Expand Down
13 changes: 8 additions & 5 deletions packages/core/src/verification-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function createVerificationController({
}
}

async function start(template) {
async function start({template}: {template: string}) {
setState(VerificationStatus.LoadingTemplate);

// check for dids
Expand All @@ -86,10 +86,8 @@ export function createVerificationController({
throw new Error('No DIDs in the wallet');
}

if (dids.length === 1) {
selectedDID = dids[0];
}

// the application needs to verify if there are more DIDs available, and allow the user to change this selection before creating a presentation
selectedDID = dids[0].id;
templateJSON = await getJSON(template);

await fetchProvingKey(templateJSON);
Expand Down Expand Up @@ -202,13 +200,18 @@ export function createVerificationController({
return statusData;
}

function setSelectedDID(did: string) {
selectedDID = did;
}

return {
emitter,
getStatus,
getStatusData,
getSelectedDID() {
return selectedDID;
},
setSelectedDID,
start,
loadCredentials,
getSelectedAttributes,
Expand Down

0 comments on commit fc111ec

Please sign in to comment.