Skip to content

Commit 439eb3d

Browse files
getDelay unit tests
1 parent 8e0a1e3 commit 439eb3d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/sync/streaming/__tests__/parseUtils.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,14 @@ test('split notification - parseKeyList', () => {
6262
});
6363

6464
test('getDelay', () => {
65+
// if h === 0, return 0 (immediate, no delay)
66+
expect(getDelay({ i: 300, h: 0, s: 1 }, 'anything')).toBe(0);
67+
68+
// if h !== 0, calculate delay with provided hash, seed and interval
6569
expect(getDelay({ i: 300, h: 1, s: 0 }, '[email protected]')).toBe(241);
6670
expect(getDelay({ i: 60000, h: 1, s: 1 }, '[email protected]')).toBe(14389);
6771
expect(getDelay({ i: 60000, h: 1, s: 0 }, '[email protected]')).toBe(24593);
72+
73+
// if i, h and s are not provided, use defaults
6874
expect(getDelay({}, '[email protected]')).toBe(24593);
6975
});

0 commit comments

Comments
 (0)