Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a961147
saving
raju-opti Aug 22, 2024
eb9110c
saving
raju-opti Aug 27, 2024
f88fd9f
up
raju-opti Aug 27, 2024
c406523
fix test
raju-opti Aug 28, 2024
de99436
fix more tests
raju-opti Aug 29, 2024
ef85d65
fix tests
raju-opti Aug 29, 2024
580a0b6
saving
raju-opti Aug 30, 2024
7940193
saving
raju-opti Sep 2, 2024
08636b7
emitter test
raju-opti Sep 3, 2024
f1a68e4
save
raju-opti Sep 4, 2024
5439eb2
fix more test
raju-opti Sep 5, 2024
2ff16c9
fix tests
raju-opti Sep 5, 2024
a5305f9
fix tests
raju-opti Sep 5, 2024
9c6e8ee
fix
raju-opti Sep 6, 2024
2441875
update
raju-opti Sep 9, 2024
3755d24
update
raju-opti Sep 9, 2024
2d25fd5
update
raju-opti Sep 9, 2024
a086e62
saving
raju-opti Sep 10, 2024
c705ccb
add tests
raju-opti Sep 10, 2024
3c8a57c
add test
raju-opti Sep 10, 2024
b276b7e
tests
raju-opti Sep 11, 2024
cae172f
update
raju-opti Sep 13, 2024
53ccf3e
update
raju-opti Sep 13, 2024
8dea409
tests
raju-opti Sep 17, 2024
f57c315
add more tests
raju-opti Sep 17, 2024
1643628
add tests
raju-opti Sep 18, 2024
b41f28f
update
raju-opti Sep 18, 2024
0098fc2
update
raju-opti Sep 18, 2024
5758a9b
tests
raju-opti Sep 18, 2024
a71fdd9
add more tests
raju-opti Sep 19, 2024
5a29def
add tests
raju-opti Sep 19, 2024
fcbef0d
update name
raju-opti Sep 19, 2024
acf7bcf
remove notification registry
raju-opti Sep 19, 2024
4a98a6d
fix repeater test
raju-opti Sep 19, 2024
a24e263
fixes
raju-opti Sep 19, 2024
d27b3b1
updates
raju-opti Sep 20, 2024
3cc4e7c
update
raju-opti Sep 20, 2024
515696e
update
raju-opti Sep 20, 2024
f92b56f
update
raju-opti Sep 20, 2024
56ebf5e
update
raju-opti Sep 20, 2024
a877e9d
upd
raju-opti Sep 20, 2024
c2fbc70
exclude spec from build
raju-opti Sep 20, 2024
19877a2
private
raju-opti Sep 20, 2024
ef4879d
update
raju-opti Sep 27, 2024
0b8c06d
update
raju-opti Sep 27, 2024
c483d85
updating
raju-opti Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add tests
  • Loading branch information
raju-opti committed Sep 27, 2024
commit c705ccb928b9f75b1be898cd42eaf1c2ac3e1978
23 changes: 22 additions & 1 deletion lib/utils/ticker/ticker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe("IntervalTicker", () => {
expect(handler.mock.calls[3][0]).toBe(true);
});

it('should backoff when the handler fails', async() => {
it('should backoff when the handler fails if backoffController is provided', async() => {
const handler = vi.fn().mockRejectedValue(new Error());

const backoffController = {
Expand All @@ -168,6 +168,23 @@ describe("IntervalTicker", () => {
expect(backoffController.backoff).toHaveBeenCalledTimes(3);
});

it('should use the regular interval when the handler fails if backoffController is not provided', async() => {
const handler = vi.fn().mockRejectedValue(new Error());

const intervalTicker = new IntervalTicker(30000);
intervalTicker.onTick(handler);

intervalTicker.start();

await advanceTimersByTime(30000);
expect(handler).toHaveBeenCalledTimes(1);

await advanceTimersByTime(10000);
expect(handler).toHaveBeenCalledTimes(1);
await advanceTimersByTime(20000);
expect(handler).toHaveBeenCalledTimes(2);
});

it('should reset the backoffController after handler success', async () => {
const handler = vi.fn().mockRejectedValueOnce(new Error)
.mockRejectedValueOnce(new Error())
Expand Down Expand Up @@ -247,6 +264,10 @@ describe("IntervalTicker", () => {

intervalTicker.stop();

ret.resolve(undefined);
await ret.promise;

await advanceTimersByTime(2000);
await advanceTimersByTime(2000);
expect(handler).toHaveBeenCalledTimes(1);
});
Expand Down