Skip to content

Commit 2a50c5c

Browse files
committed
update timer tests
1 parent 9f9b6a1 commit 2a50c5c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

test/components/Timer.test.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ describe("Timer tests", () => {
3030
</BoardContext.Provider>
3131
);
3232

33-
timerRef.current.start();
33+
act(() => {
34+
timerRef.current.start();
35+
});
3436

3537
expect(timerRef.current.isRunning()).toBe(true);
3638
});
@@ -44,9 +46,11 @@ describe("Timer tests", () => {
4446
</BoardContext.Provider>
4547
);
4648

47-
timerRef.current.start();
48-
boardContext.ctx.gameover = { isWin: true };
49+
act(() => {
50+
timerRef.current.start();
51+
});
4952

53+
boardContext.ctx.gameover = { isWin: true };
5054
rerender(
5155
<BoardContext.Provider value={boardContext}>
5256
<Timer ref={timerRef} />
@@ -65,9 +69,8 @@ describe("Timer tests", () => {
6569
</BoardContext.Provider>
6670
);
6771

68-
timerRef.current.start();
69-
7072
act(() => {
73+
timerRef.current.start();
7174
vi.advanceTimersByTime(5000);
7275
});
7376

@@ -85,9 +88,8 @@ describe("Timer tests", () => {
8588
</BoardContext.Provider>
8689
);
8790

88-
timerRef.current.start();
89-
9091
act(() => {
92+
timerRef.current.start();
9193
vi.advanceTimersByTime(5000);
9294
});
9395

0 commit comments

Comments
 (0)