Skip to content

Commit

Permalink
test: useDashboardCreateForm 테스트 코드 수정 및 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
lurgi committed Dec 28, 2024
1 parent 80bd0b2 commit 4f05948
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion frontend/src/hooks/useDashboardCreateForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4f05948

Please sign in to comment.