From ccee93c744b26d71cf4295ec4e2769b27d1713bd Mon Sep 17 00:00:00 2001 From: nitro-neal <5314059+nitro-neal@users.noreply.github.com> Date: Thu, 15 Feb 2024 07:50:17 -0600 Subject: [PATCH] new unit test (#405) --- .../tests/presentation-exchange.spec.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packages/credentials/tests/presentation-exchange.spec.ts b/packages/credentials/tests/presentation-exchange.spec.ts index 610b7a4fb..1fc0bda09 100644 --- a/packages/credentials/tests/presentation-exchange.spec.ts +++ b/packages/credentials/tests/presentation-exchange.spec.ts @@ -167,6 +167,34 @@ describe('PresentationExchange', () => { expect(result).to.deep.equal([{ tag: 'root', status: 'info', message: 'ok' }]); }); + it('should successfully catch an invalid presentation definition', () => { + const invalidPd = { + 'id' : '', + 'input_descriptors' : [ + { + 'id' : '7b928839-f0b1-4237-893d-b27124b57952', + 'constraints' : { + 'fields': [ + { + 'path': [ + '$.vc.type[*]', + '$.type[*]' + ], + 'filter': { + 'type' : 'string', + 'pattern' : '.*StreetCred.*' + } + } + ] + } + } + ] + }; + + const result:Validated = PresentationExchange.validateDefinition({ presentationDefinition: invalidPd }); + expect(result).to.deep.equal([{ tag: 'root.presentation_definition', status: 'error', message: 'id should not be empty' }]); + }); + it('should successfully validate a submission', () => { const presentationResult = PresentationExchange.createPresentationFromCredentials({ vcJwts: [btcCredentialJwt],