Skip to content

Commit

Permalink
fix: Increase test coverage for verifyPresentationSubmission
Browse files Browse the repository at this point in the history
  • Loading branch information
elribonazo committed Apr 25, 2024
1 parent 24dc8d8 commit 951efd0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pollux/Pollux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default class Pollux implements IPollux {

parsePresentationSubmission(data: any): data is PresentationSubmission {
//Validate object
if (typeof data !== "object") {
if (!data || (data && typeof data !== "object")) {
return false;
}

Expand Down
24 changes: 24 additions & 0 deletions tests/pollux/Pollux.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,30 @@ describe("Pollux", () => {
);
})

it("Should throw an error if presentationSubmission is not an object", async () => {
expect(pollux.verifyPresentationSubmission(null as any, {
presentationDefinitionRequest: null as any
})).to.eventually.be.rejectedWith(
`Verification format is invalid: reason -> PresentationSubmission format is invalid`
);
})

it("Should throw an error if the actual presentationSubmission is not an object", async () => {
expect(pollux.verifyPresentationSubmission({ presentation_submission: null, verifiablePresentation: null } as any, {
presentationDefinitionRequest: null as any
})).to.eventually.be.rejectedWith(
`Verification format is invalid: reason -> PresentationSubmission format is invalid`
);
})

it("Should throw an error if the actual presentationSubmission.verifiablePresentation is not an array", async () => {
expect(pollux.verifyPresentationSubmission({ presentation_submission: {}, verifiablePresentation: null } as any, {
presentationDefinitionRequest: null as any
})).to.eventually.be.rejectedWith(
`Verification format is invalid: reason -> PresentationSubmission format is invalid`
);
})

it("Should Verify false when the Credential subject does not provide required field", async () => {
const issuerSeed = apollo.createRandomSeed().seed;
const holderSeed = apollo.createRandomSeed().seed;
Expand Down

0 comments on commit 951efd0

Please sign in to comment.