File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,14 +32,15 @@ jest.mock("@/apis/goalApi", () => ({
3232} ) ) ;
3333
3434describe ( "목표 생성 테스트" , ( ) => {
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
You can’t perform that action at this time.
0 commit comments