@microsoft/useragent-sdk
Version:
SDK for building decentralized identity wallets and enterprise agents.
41 lines • 1.98 kB
JavaScript
;
/*---------------------------------------------------------------------------------------------
* 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 UserServiceEndpoint_1 = require("../../src/serviceEndpoints/UserServiceEndpoint");
const context = 'test.schema.identity.foundation/hub';
const instance = 'did:test:hub.id';
describe('UserServiceEndpoint', () => {
const mockServiceEndpoint = {
instances: [
'did:test:hub.id'
],
'@context': 'test.schema.identity.foundation/hub',
'@type': 'UserServiceEndpoint'
};
let mockServiceEndpointStr;
let endpoint;
beforeAll(() => {
endpoint = new UserServiceEndpoint_1.default(context, [instance]);
mockServiceEndpointStr = JSON.stringify(mockServiceEndpoint);
});
it('should create a new UserServiceEndpoint object', () => {
expect(endpoint).toBeDefined();
expect(endpoint instanceof UserServiceEndpoint_1.default).toBeTruthy();
expect(endpoint.type).toEqual('UserServiceEndpoint');
expect(endpoint.context).toEqual(context);
expect(endpoint.instances[0]).toEqual(instance);
});
it('should serialize UserServiceEndpoint', () => {
const serviceEndpointStr = JSON.stringify(endpoint);
expect(serviceEndpointStr).toEqual(mockServiceEndpointStr);
});
it('should deserialize UserServiceEndpoint', () => {
const serviceEndpoint = UserServiceEndpoint_1.default.fromJSON(JSON.parse(mockServiceEndpointStr));
console.log(serviceEndpoint);
expect(serviceEndpoint).toEqual(endpoint);
});
});
//# sourceMappingURL=UserServiceEndpoint.spec.js.map