Skip to content

Commit 278d7ff

Browse files
committed
test: 성공 시 무효화 테스트 코드 추가
1 parent ee82aba commit 278d7ff

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/views/layouts/sidebar/components/goals/menu-goal/MenuGoal.test.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ jest.mock("@/apis/goalApi", () => ({
3232
}));
3333

3434
describe("목표 생성 테스트", () => {
35+
let queryClient: QueryClient;
3536
let form: HTMLElement;
3637
let input: HTMLElement | null;
3738

3839
let wrapper: ({ children }: PropsWithChildren) => JSX.Element;
3940

4041
// MenuGoal render 후 새 목표 버튼 클릭
4142
beforeEach(async () => {
42-
const queryClient = new QueryClient();
43+
queryClient = new QueryClient();
4344
queryClient.invalidateQueries = jest.fn();
4445

4546
wrapper = ({ children }: PropsWithChildren) => (
@@ -87,7 +88,7 @@ describe("목표 생성 테스트", () => {
8788
});
8889
});
8990

90-
test("input에 값이 있고, 제출 성공 시 성공 토스트 호출", async () => {
91+
test("input에 값이 있고, 제출 성공 시 성공 토스트 호출 및 쿼리 데이터 무효화", async () => {
9192
(goalApi.createGoal as jest.Mock).mockResolvedValue({
9293
id: 1,
9394
title: "New Goal",
@@ -113,6 +114,9 @@ describe("목표 생성 테스트", () => {
113114
}),
114115
}),
115116
);
117+
118+
// 무효화
119+
expect(queryClient.invalidateQueries).toHaveBeenCalledTimes(1);
116120
});
117121
});
118122

0 commit comments

Comments
 (0)