@microsoft/useragent-sdk
Version:
SDK for building decentralized identity wallets and enterprise agents.
59 lines • 2.74 kB
JavaScript
;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
const HubCommitQueryResponse_1 = require("../../../src/hubSession/responses/HubCommitQueryResponse");
const JoseToken_1 = require("../../../src/crypto/protocols/jose/JoseToken");
const ProtocolTest_1 = require("../../crypto/protocols/jose/ProtocolTest");
const JoseConstants_1 = require("../../../src/crypto/protocols/jose/JoseConstants");
const ProtectionFormat_1 = require("../../../src/crypto/keyStore/ProtectionFormat");
const token = new JoseToken_1.default({}, new ProtocolTest_1.default(), [
[JoseConstants_1.default.tokenFormat, ProtectionFormat_1.ProtectionFormat.JwsFlatJson],
[JoseConstants_1.default.tokenPayload, 'test'],
[JoseConstants_1.default.tokenProtected, 'test'],
[JoseConstants_1.default.tokenSignatures, ['test']]
]);
describe('HubCommitQueryResponse', () => {
let response;
beforeAll(() => {
response = new HubCommitQueryResponse_1.default({
'@context': 'https://schema.identity.foundation/0.1',
'@type': 'CommitQueryResponse',
commits: [token],
skip_token: 'abc',
});
});
describe('constructor', () => {
it('should throw on an invalid response type', async () => {
try {
const r = new HubCommitQueryResponse_1.default({
'@type': 'WrongType',
});
fail(`Constructor was expected to throw: '${r}'`);
}
catch (e) {
// Expected
}
});
});
describe('getCommits()', () => {
it('should return the matching commits', async () => {
const returnedCommits = await response.getCommits();
expect(returnedCommits.length).toEqual(1);
expect(returnedCommits[0].toFlattenedJson()).toEqual(token);
});
});
describe('hasSkipToken()', () => {
it('should indicate whether a skip token was returned', async () => {
expect(response.hasSkipToken()).toEqual(true);
});
});
describe('getSkipToken()', () => {
it('should return the skip token', async () => {
expect(response.getSkipToken()).toEqual('abc');
});
});
});
//# sourceMappingURL=HubCommitQueryResponse.spec.js.map