-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixed some issue in the IssuerMetadataUtils plus added some unit…
…tests for it
- Loading branch information
Showing
2 changed files
with
51 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { getTypesFromCredentialSupported } from '../functions'; | ||
import { CredentialConfigurationSupportedV1_0_13 } from '../types'; | ||
|
||
describe('IssuerMetadataUtils should', () => { | ||
it('return the types from a credential supported with jwt_vc_json format', () => { | ||
const credentialSupported: CredentialConfigurationSupportedV1_0_13 = { | ||
format: 'jwt_vc_json', | ||
credential_definition: { | ||
type: ['VerifiableCredential', 'BevoegdheidUittreksel'], | ||
}, | ||
}; | ||
|
||
const result: string[] = getTypesFromCredentialSupported(credentialSupported); | ||
expect(result).toEqual(['VerifiableCredential', 'BevoegdheidUittreksel']); | ||
}); | ||
|
||
it('filter out "VerifiableCredential" type if filterVerifiableCredential option is true', () => { | ||
const credentialSupported: CredentialConfigurationSupportedV1_0_13 = { | ||
format: 'jwt_vc_json', | ||
credential_definition: { | ||
type: ['VerifiableCredential', 'BevoegdheidUittreksel'], | ||
}, | ||
}; | ||
|
||
const result: string[] = getTypesFromCredentialSupported(credentialSupported, { filterVerifiableCredential: true }); | ||
expect(result).toEqual(['BevoegdheidUittreksel']); | ||
}); | ||
|
||
it('throw an error if types cannot be deduced', () => { | ||
const credentialSupported: CredentialConfigurationSupportedV1_0_13 = { | ||
format: 'unknown_format', | ||
} as unknown as CredentialConfigurationSupportedV1_0_13; | ||
|
||
expect(() => { | ||
getTypesFromCredentialSupported(credentialSupported); | ||
}).toThrow('Could not deduce types from credential supported'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters