Skip to content

Commit f62a12a

Browse files
committed
test: add comments and assertions
1 parent c787491 commit f62a12a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/__tests__/helpers.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,17 @@ describe('run with real timers', () => {
5353
const realSetTimeout = global.setTimeout
5454

5555
afterEach(() => {
56+
// restore timers replaced by jest.useFakeTimers()
5657
jest.useRealTimers()
58+
// restore setTimeout replaced by assignment
5759
global.setTimeout = realSetTimeout
5860
})
5961

6062
test('use real timers when timers are faked with jest.useFakeTimers(legacy)', () => {
6163
// legacy timers use mocks and do not rely on a clock instance
6264
jest.useFakeTimers('legacy')
6365
runWithRealTimers(() => {
64-
expect(global.setTimeout).toEqual(realSetTimeout)
66+
expect(global.setTimeout).toBe(realSetTimeout)
6567
})
6668
expect(global.setTimeout._isMockFunction).toBe(true)
6769
expect(global.setTimeout.clock).toBeUndefined()
@@ -71,7 +73,7 @@ describe('run with real timers', () => {
7173
// modern timers use a clock instance instead of a mock
7274
jest.useFakeTimers('modern')
7375
runWithRealTimers(() => {
74-
expect(global.setTimeout).toEqual(realSetTimeout)
76+
expect(global.setTimeout).toBe(realSetTimeout)
7577
})
7678
expect(global.setTimeout._isMockFunction).toBeUndefined()
7779
expect(global.setTimeout.clock).toBeDefined()
@@ -86,7 +88,8 @@ describe('run with real timers', () => {
8688
global.setTimeout = fakedSetTimeout
8789

8890
runWithRealTimers(() => {
89-
expect(global.setTimeout).toEqual(fakedSetTimeout)
91+
expect(global.setTimeout).toBe(fakedSetTimeout)
9092
})
93+
expect(global.setTimeout).toBe(fakedSetTimeout)
9194
})
9295
})

0 commit comments

Comments
 (0)