UNPKG

@microsoft/useragent-sdk

Version:

SDK for building decentralized identity wallets and enterprise agents.

97 lines 3.86 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License in the project root for license information. *--------------------------------------------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); const CredentialManifest_1 = require("../../src/credentials/CredentialManifest"); describe('ClaimManifest', () => { const testCredential = 'TestCredential'; const testLanguage = ['en']; const testKeeper = 'did:test:example123'; const testVersion = 'v1'; const testEndpoint = 'endpoint.org'; const testPreconditions = { '@type': 'ProofSet', 'groups': [ { rule: 'all', from: ['A'] } ] }; const testInputs = [ { type: 'data', group: ['A'], field: 'routing_number', value: { type: 'string' } } ]; const testStyles = { test: 'test' }; const testLabels = { routing_number: 'test routing number' }; const testPresentation = { issuer_name: 'Test', credential_name: 'Test Credential', description: 'test description', claims: { test: { label: 'Test Claim', type: 'string', value: 'routing_number' } }, styles: testStyles }; const testIssuerOptions = { input: { styles: testStyles, labels: testLabels }, presentation: testPresentation }; const testManifest = { '@context': 'https://identity.foundation/schemas/credentials', '@type': 'CredentialManifest', 'credential': testCredential, 'endpoint': testEndpoint, 'preconditions': testPreconditions, 'inputs': testInputs, 'issuer_options': testIssuerOptions }; let credentialManifest; beforeEach(() => { credentialManifest = CredentialManifest_1.default.create(testCredential, testEndpoint, testLanguage, testKeeper, testVersion, testPreconditions, testInputs, testIssuerOptions); }); it('should create a new CredentialManifest Object', () => { spyOn(CredentialManifest_1.default, 'create').and.callThrough(); const manifest = CredentialManifest_1.default.create(testCredential, testCredential, testLanguage, testKeeper, testVersion, testPreconditions, testInputs, testIssuerOptions); expect(CredentialManifest_1.default.create).toHaveBeenCalled(); expect(manifest).toBeDefined(); }); it('should serialize a CredentialManifest correctly', () => { spyOn(credentialManifest, 'toJSON').and.callThrough(); const manifest = credentialManifest.toJSON(); expect(credentialManifest.toJSON).toHaveBeenCalled(); expect(manifest).toEqual(testManifest); }); it('should get Keeper DID', () => { spyOn(credentialManifest, 'getKeeperDid').and.callThrough(); const keeper = credentialManifest.getKeeperDid(); expect(credentialManifest.getKeeperDid).toHaveBeenCalled(); expect(keeper).toEqual(testKeeper); }); it('should get Input Properties', () => { spyOn(credentialManifest, 'getInputProperties').and.callThrough(); const inputProperties = credentialManifest.getInputProperties(); expect(credentialManifest.getInputProperties).toHaveBeenCalled(); expect(inputProperties).toEqual(testInputs); }); }); //# sourceMappingURL=CredentialManifest.spec.js.map