Skip to content

Commit

Permalink
complete coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Oct 18, 2024
1 parent 1715a8c commit c5b94c2
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/agent/tests/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { expect } from 'chai';
import sinon from 'sinon';

import { DateSort, Message, TestDataGenerator } from '@tbd54566975/dwn-sdk-js';
import { DateSort, Jws, Message, TestDataGenerator } from '@tbd54566975/dwn-sdk-js';
import { getPaginationCursor, getRecordAuthor, getRecordMessageCid, getRecordProtocolRole } from '../src/utils.js';

describe('Utils', () => {
beforeEach(() => {
sinon.restore();
});

after(() => {
sinon.restore();
});

describe('getPaginationCursor', () => {
it('should return a PaginationCursor object', async () => {
// create a RecordWriteMessage object which is published
Expand Down Expand Up @@ -107,5 +116,12 @@ describe('Utils', () => {
const deleteRole = getRecordProtocolRole(recordsDelete.message);
expect(deleteRole).to.be.undefined;
});

it('returns undefined if decodedObject is undefined', async () => {
sinon.stub(Jws, 'decodePlainObjectPayload').returns(undefined);
const recordsWrite = await TestDataGenerator.generateRecordsWrite();
const writeRole = getRecordProtocolRole(recordsWrite.message);
expect(writeRole).to.be.undefined;
});
});
});

0 comments on commit c5b94c2

Please sign in to comment.