Skip to content

Commit 657e3fc

Browse files
committed
fix tests
1 parent e777d38 commit 657e3fc

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/components/v2v3/V2V3Project/ProjectDashboard/hooks/useCountdownClock.test.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ describe('useCountdownClock', () => {
1616
const now = Date.now() / 1000
1717
const tenSecondsFromNow = now + 10
1818
const { result } = renderHook(() => useCountdownClock(tenSecondsFromNow))
19-
expect(result.current).toEqual('0d 0h 0m 10s')
19+
expect(result.current).toEqual({
20+
remainingTimeText: '0d 0h 0m 10s',
21+
secondsRemaining: 10,
22+
})
2023
})
2124
it('updates every second', () => {
2225
const now = Date.now() / 1000
2326
const tenSecondsFromNow = now + 10
2427
const { result } = renderHook(() => useCountdownClock(tenSecondsFromNow))
2528
for (let i = 10; i >= 0; i--) {
26-
expect(result.current).toEqual(`0d 0h 0m ${i}s`)
29+
expect(result.current).toEqual({
30+
remainingTimeText: `0d 0h 0m ${i}s`,
31+
secondsRemaining: i,
32+
})
2733
act(() => jest.advanceTimersByTime(1000))
2834
}
2935
})
@@ -32,7 +38,10 @@ describe('useCountdownClock', () => {
3238
const now = Date.now() / 1000
3339
const tenSecondsAgo = now - 10
3440
const { result } = renderHook(() => useCountdownClock(tenSecondsAgo))
35-
expect(result.current).toEqual('0d 0h 0m 0s')
41+
expect(result.current).toEqual({
42+
remainingTimeText: '0d 0h 0m 0s',
43+
secondsRemaining: 0,
44+
})
3645
})
3746

3847
test('timer is cleared on unmount', () => {
@@ -41,15 +50,24 @@ describe('useCountdownClock', () => {
4150
const { result, unmount } = renderHook(() =>
4251
useCountdownClock(tenSecondsFromNow),
4352
)
44-
expect(result.current).toEqual('0d 0h 0m 10s')
53+
expect(result.current).toEqual({
54+
remainingTimeText: '0d 0h 0m 10s',
55+
secondsRemaining: 10,
56+
})
4557
act(() => {
4658
jest.advanceTimersByTime(1000)
4759
})
48-
expect(result.current).toEqual('0d 0h 0m 9s')
60+
expect(result.current).toEqual({
61+
remainingTimeText: '0d 0h 0m 9s',
62+
secondsRemaining: 9,
63+
})
4964
unmount()
5065
act(() => {
5166
jest.advanceTimersByTime(1000)
5267
})
53-
expect(result.current).toEqual('0d 0h 0m 9s')
68+
expect(result.current).toEqual({
69+
remainingTimeText: '0d 0h 0m 9s',
70+
secondsRemaining: 9,
71+
})
5472
})
5573
})

0 commit comments

Comments
 (0)