Skip to content

Commit 2db3cc1

Browse files
committed
feat: set up new test for beat twice
1 parent 4e93db5 commit 2db3cc1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/unit/node/heart.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ describe("Heart", () => {
7575
const isAlive = heart.alive()
7676
expect(isAlive).toBe(false)
7777
})
78+
it("should beat twice and maintain reference to Heart", async () => {
79+
// Use fake timers so we can speed up setTimeout
80+
jest.useFakeTimers()
81+
heart = new Heart(`${testDir}/hello.txt`, mockIsActive(true))
82+
heart.beat()
83+
// we need to speed up clocks, timeouts
84+
// call heartbeat again (and it won't be alive I think)
85+
// then assert no warnings were called
86+
jest.runAllTimers()
87+
expect(logger.warn).not.toHaveBeenCalled()
88+
})
7889
})
7990

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

0 commit comments

Comments
 (0)