Skip to content

Commit 4d29cd5

Browse files
committed
feat(heart): add test to ensure no warnings called
1 parent 79ce2b5 commit 4d29cd5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/unit/node/heart.test.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,17 @@ describe("Heart", () => {
6868
const isAlive = heart.alive()
6969
expect(isAlive).toBe(false)
7070
})
71-
it.todo("should beat twice without warnings")
71+
it("should beat twice without warnings", async () => {
72+
// Use fake timers so we can speed up setTimeout
73+
jest.useFakeTimers()
74+
heart = new Heart(`${testDir}/hello.txt`, mockIsActive(true))
75+
await heart.beat()
76+
// we need to speed up clocks, timeouts
77+
// call heartbeat again (and it won't be alive I think)
78+
// then assert no warnings were called
79+
jest.runAllTimers()
80+
expect(logger.warn).not.toHaveBeenCalled()
81+
})
7282
})
7383

7484
describe("heartbeatTimer", () => {

0 commit comments

Comments
 (0)