Skip to content

Commit

Permalink
chore: improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderPostma committed Oct 31, 2024
1 parent 18f4c20 commit 6edaca7
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions test/evaluation/selectFrom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1049,9 +1049,13 @@ describe('selectFrom tests', () => {
const presentationResult = pex.presentationFrom(pd, result.verifiableCredential!);
expect(presentationResult).toBeDefined();
expect(result.errors).toHaveLength(0);
const cred = await SDJwt.fromEncode(presentationResult.presentations[1].compactSdJwtVc, hasher);
const claims = await cred.getClaims<Record<string, ClaimValue>>(hasher);

const eOrder = await SDJwt.fromEncode(presentationResult.presentations[0].compactSdJwtVc, hasher);
const ePassport = await SDJwt.fromEncode(presentationResult.presentations[1].compactSdJwtVc, hasher);
const claims = {
...await eOrder.getClaims<Record<string, ClaimValue>>(hasher),
...await ePassport.getClaims<Record<string, ClaimValue>>(hasher)
}

console.log(claims);

// Check data group 1
Expand All @@ -1069,6 +1073,21 @@ describe('selectFrom tests', () => {
expect((claims.electronicPassport as Record<string, Record<string, unknown>>).dataGroup15.activeAuthentication).toEqual({});
expect((claims.electronicPassport as Record<string, Record<string, unknown>>).digitalTravelCredential).toEqual({});

// Check order structure
expect(claims.order).toBeDefined()
expect((claims.order as { paxSegments: unknown[] }).paxSegments).toBeDefined()
expect(Array.isArray((claims.order as { paxSegments: unknown[] }).paxSegments)).toBe(true)

// Additional top-level claims checks
expect(claims.vct).toBe('epassport_copy_vc')
expect(claims.type).toBe('epassport_copy_vc')
expect(claims.iss).toBe('did:web:agent.nb.dev.sphereon.com')

// Check cnf object
expect(claims.cnf).toEqual({
kid: 'did:jwk:eyJhbGciOiJFUzI1NiIsInVzZSI6InNpZyIsImt0eSI6IkVDIiwiY3J2IjoiUC0yNTYiLCJ4IjoiWUM5aE1keUNSVXBwbmpzWnlPbHl2dmpCY2JNdW5Nb3ZxdS1JVUJPd1VhYyIsInkiOiJmeW9XRE9ZMGZXRHRiWnN4eEs0VXJMZGc5c2JLRXlqa1d3U096dUQxLUtnIn0#0'
})

// Top level claims
expect(claims.vct).toBe('epassport_copy_vc');
expect(claims.type).toBe('epassport_copy_vc');
Expand Down

0 comments on commit 6edaca7

Please sign in to comment.