Skip to content

Commit

Permalink
Add suite & documentLoader & await issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed Nov 27, 2023
1 parent 3f5cded commit 4254390
Showing 1 changed file with 48 additions and 8 deletions.
56 changes: 48 additions & 8 deletions test/10-verify.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,61 +152,101 @@ for(const [version, mockCredential] of versionedCredentials) {
.contain('"suite.verificationMethod" property is required.');
});
if(version === 2.0) {
it('should issue "validUntil" in the future', () => {
it('should issue "validUntil" in the future', async () => {
const credential = jsonld.clone(mockCredential);
credential.issuer = 'did:example:12345';
credential.validUntil = '2025-10-31T19:21:25Z';
const now = '2022-06-30T19:21:25Z';
let error;
let result;
try {
vc.issue({credential, now});
result = await vc.issue({
credential,
now,
suite,
documentLoader
});
} catch(e) {
error = e;
}
should.not.exist(error,
'Should not throw error when issuing "validUntil" in future');
should.exist(
result,
'Expected a VC with "validUntil" in the future to be issued'
);
});
it('should issue "validUntil" in the past', () => {
it('should issue "validUntil" in the past', async () => {
const credential = jsonld.clone(mockCredential);
credential.issuer = 'did:example:12345';
credential.validUntil = '2025-10-31T19:21:25Z';
const now = '2022-06-30T19:21:25Z';
let error;
let result;
try {
vc.issue({credential, now});
result = await vc.issue({
credential,
now,
suite,
documentLoader
});
} catch(e) {
error = e;
}
should.not.exist(error,
'Should not throw error when issuing with "validUntil" in past');
should.exist(
result,
'Expected a VC with "validUntil" in the past to be issued'
);
});
it('should issue "validFrom" in the past', () => {
it('should issue "validFrom" in the past', async () => {
const credential = jsonld.clone(mockCredential);
credential.issuer = 'did:example:12345';
credential.validFrom = '2022-06-30T19:21:25Z';
const now = '2022-10-30T19:21:25Z';
let error;
let result;
try {
vc.issue({credential, now});
result = await vc.issue({
credential,
now,
suite,
documentLoader
});
} catch(e) {
error = e;
}
should.not.exist(error,
'Should not throw error when issuing "validFrom" in past');
should.exist(
result,
'Expected a VC with "validFrom" in the past to be issued'
);
});
it('should issue "validFrom" in the future', () => {
it('should issue "validFrom" in the future', async () => {
const credential = jsonld.clone(mockCredential);
credential.issuer = 'did:example:12345';
credential.validFrom = '2022-10-30T19:21:25Z';
const now = '2022-06-30T19:21:25Z';
let error;
let result;
try {
vc.issue({credential, now});
result = await vc.issue({
credential,
now,
suite,
documentLoader
});
} catch(e) {
error = e;
}
should.not.exist(error,
'Should not throw error when issuing "validFrom" in future');
should.exist(
result,
'Expected a VC with "validFrom" in the future to be issued'
);
});
}
});
Expand Down

0 comments on commit 4254390

Please sign in to comment.