Skip to content

Commit

Permalink
add deep equal test on positive result
Browse files Browse the repository at this point in the history
  • Loading branch information
jchartrand committed Jan 10, 2025
1 parent 1f4c5f7 commit 0b47854
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
},
"devDependencies": {
"@types/chai": "^4.3.4",
"@types/deep-equal-in-any-order": "^1.0.4",
"@types/mocha": "^10.0.1",
"@types/node": "^18.11.17",
"@typescript-eslint/eslint-plugin": "^5.46.1",
"@typescript-eslint/parser": "^5.46.1",
"chai": "^4.3.7",
"cross-env": "^7.0.3",
"deep-equal-in-any-order": "^2.0.6",
"eslint": "^8.30.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard-with-typescript": "^24.0.0",
Expand Down
41 changes: 39 additions & 2 deletions test/Verify.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
import { expect } from 'chai'
import chai from 'chai'
import deepEqualInAnyOrder from 'deep-equal-in-any-order'
import { strict as assert } from 'assert';
import { verifyCredential } from '../src/Verify'
import { getVCv2Expired, getVCv1Tampered, getVCv2ValidStatus } from '../src/test-fixtures/vc'
import { knownDIDRegistries } from '../.knownDidRegistries';

chai.use(deepEqualInAnyOrder);
const {expect} = chai;

const expectedResult = {
"verified": true,
"log": [
{
"id": "valid_signature",
"valid": true
},
{
"id": "issuer_did_resolves",
"valid": true
},
{
"id": "expiration",
"valid": true
},
{
"id": "revocation_status",
"valid": true
},
{
"id": "registered_issuer",
"valid": true,
"foundInRegistries": [
"DCC Sandbox Registry"
]
}
],
credential: null,
"isFatal": false
}

describe('Verify', () => {
it('verifies with valid status', async () => {
it.only('verifies with valid status', async () => {
const credential : any = getVCv2ValidStatus()
expectedResult.credential = credential;
const result = await verifyCredential({credential, reloadIssuerRegistry: true, knownDIDRegistries})
console.log("result returned from verifyCredential call:")
console.log(JSON.stringify(result,null,2))
expect(result.verified).to.be.true
expect(result.credential).to.eql(credential)
expect(result).to.deep.equalInAnyOrder(expectedResult) // eslint-disable-line no-use-before-define
})

it('returns fatal error when tampered', async () => {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"lib": ["es2022", "dom"],
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"outDir": "dist/esm",
"noImplicitAny": true,
"removeComments": false,
Expand Down

0 comments on commit 0b47854

Please sign in to comment.