diff --git a/frontend/src/hooks/useDashboardCreateForm/index.tsx b/frontend/src/hooks/useDashboardCreateForm/index.tsx index 0cf0dbee..2d7f217d 100644 --- a/frontend/src/hooks/useDashboardCreateForm/index.tsx +++ b/frontend/src/hooks/useDashboardCreateForm/index.tsx @@ -164,7 +164,7 @@ export default function useDashboardCreateForm(): UseDashboardCreateFormReturn { const setQuestionPrev = (index: number) => () => { setApplyState((prevState) => { - if (index > DEFAULT_QUESTIONS.length + 1) { + if (index > DEFAULT_QUESTIONS.length) { const questionsCopy = [...prevState]; const temp = questionsCopy[index]; questionsCopy[index] = questionsCopy[index - 1]; diff --git a/frontend/src/hooks/useDashboardCreateForm/useDashboardCreateForm.test.tsx b/frontend/src/hooks/useDashboardCreateForm/useDashboardCreateForm.test.tsx index 3ff5b060..4d92ec39 100644 --- a/frontend/src/hooks/useDashboardCreateForm/useDashboardCreateForm.test.tsx +++ b/frontend/src/hooks/useDashboardCreateForm/useDashboardCreateForm.test.tsx @@ -77,17 +77,17 @@ describe('useDashboardCreateForm', () => { expect(result.current.applyState).toEqual(initialQuestions); }); - it('인덱스가 1에서 4인 질문은 prev할 수 없다.', () => { + it('인덱스가 0에서 3인 질문은 prev할 수 없다.', () => { const { result } = renderHook(() => useDashboardCreateForm(), { wrapper: createWrapper() }); act(() => result.current.addQuestion()); const expectQuestions = result.current.applyState; act(() => { + result.current.setQuestionPrev(0)(); result.current.setQuestionPrev(1)(); result.current.setQuestionPrev(2)(); result.current.setQuestionPrev(3)(); - result.current.setQuestionPrev(4)(); }); expect(result.current.applyState).toEqual(expectQuestions);