diff --git a/frontend/src/pages/GamePage/components/SelectContainer/Timer/Timer.test.tsx b/frontend/src/pages/GamePage/components/SelectContainer/Timer/Timer.test.tsx index 2927d59d8..a3c634662 100644 --- a/frontend/src/pages/GamePage/components/SelectContainer/Timer/Timer.test.tsx +++ b/frontend/src/pages/GamePage/components/SelectContainer/Timer/Timer.test.tsx @@ -1,6 +1,3 @@ -import { act, renderHook } from '@testing-library/react'; - -import useTimer from './hooks/useTimer'; import { convertMsecToSecond, formatLeftRoundTime } from './Timer.util'; describe('Timer 테스트', () => { @@ -17,56 +14,4 @@ describe('Timer 테스트', () => { expect(convertedTime).toBe(10); }); }); - describe('Timer 훅 테스트', () => { - jest.useFakeTimers(); - const voteMock = jest.fn(); - const timeLimit = 10; - const timeLimitMs = timeLimit * 1000; - - it('타이머가 종료되었을 때 선택 완료를 누르지 않아도 선택된 옵션이 있으면 투표한다.', () => { - const isSelectedOption = true; - const isVoted = false; - - const { result } = renderHook(() => - useTimer({ timeLimit, isSelectedOption, isVoted, vote: voteMock }), - ); - - act(() => { - jest.advanceTimersByTime(timeLimitMs); - }); - - expect(result.current.leftRoundTime).toBe(0); - expect(voteMock).toHaveBeenCalled(); - }); - it('타이머가 종료되었을 때 이미 투표를 했다면 또 투표를 하지 않는다.', () => { - const isSelectedOption = true; - const isVoted = true; - - const { result } = renderHook(() => - useTimer({ timeLimit, isSelectedOption, isVoted, vote: voteMock }), - ); - - act(() => { - jest.advanceTimersByTime(timeLimitMs); - }); - - expect(result.current.leftRoundTime).toBe(0); - expect(voteMock).not.toHaveBeenCalled(); - }); - it('타이머가 종료되었을 때 선택된 옵션이 없다면 투표되지 않고 기권한다.', () => { - const isSelectedOption = false; - const isVoted = false; - - const { result } = renderHook(() => - useTimer({ timeLimit, isSelectedOption, isVoted, vote: voteMock }), - ); - - act(() => { - jest.advanceTimersByTime(timeLimitMs); - }); - - expect(result.current.leftRoundTime).toBe(0); - expect(voteMock).not.toHaveBeenCalled(); - }); - }); });