Skip to content

Commit

Permalink
update test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Sep 26, 2023
1 parent 4e611fc commit c21b727
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/agent/tests/sync-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ describe('SyncManagerLevel', () => {
syncSpy.restore();
});

it('sync interval below minimum allowed threshold will sync at the minimum interval', async () => {
const syncSpy = sinon.spy(testAgent.agent.syncManager, 'sync');
await testAgent.agent.syncManager.registerIdentity({
did: alice.did
});
testAgent.agent.syncManager.startSync({ interval: 100 });

clock.tick(3 * MIN_SYNC_INTERVAL);

expect(syncSpy.callCount).to.equal(3);
syncSpy.restore();
});

it('subsequent startSync should cancel the old sync and start a new sync interval', async () => {
const syncSpy = sinon.spy(testAgent.agent.syncManager, 'sync');
await testAgent.agent.syncManager.registerIdentity({
Expand Down Expand Up @@ -258,6 +271,22 @@ describe('SyncManagerLevel', () => {

}).timeout(10_000);

it('should skip dwn if there a failure getting syncState', async () => {
await testAgent.agent.syncManager.registerIdentity({
did: alice.did
});

Check failure on line 277 in packages/agent/tests/sync-manager.spec.ts

View workflow job for this annotation

GitHub Actions / test-with-node

Trailing spaces not allowed

const getWatermarkStub = sinon.stub(testAgent.agent.syncManager as any, 'getSyncState').rejects('rejected');
const getSyncPeerState = sinon.spy(testAgent.agent.syncManager as any, 'getSyncPeerState');

await testAgent.agent.syncManager.sync();
getWatermarkStub.restore();
getSyncPeerState.restore();

expect(getSyncPeerState.called).to.be.true;
expect(getWatermarkStub.called).to.be.true;
});

describe('batchOperations()', () => {
it('should only call once per remote DWN if pull direction is passed', async () => {
const batchOperationsSpy = sinon.spy(testAgent.agent.syncManager as any, 'batchOperations');
Expand Down

0 comments on commit c21b727

Please sign in to comment.