File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
packages/react-query/src/__tests__ Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 77 QueryClient ,
88 QueryClientProvider ,
99 useInfiniteQuery ,
10+ useMutation ,
11+ useMutationState ,
1012 useQuery ,
1113} from '..'
1214import { setIsServer } from './utils'
@@ -173,4 +175,38 @@ describe('Server Side Rendering', () => {
173175
174176 queryCache . clear ( )
175177 } )
178+
179+ it ( 'useMutation should return idle status' , ( ) => {
180+ function Page ( ) {
181+ const mutation = useMutation ( {
182+ mutationFn : ( ) => sleep ( 10 ) . then ( ( ) => 'data' ) ,
183+ } )
184+
185+ return < div > { `status: ${ mutation . status } ` } </ div >
186+ }
187+
188+ const markup = renderToString (
189+ < QueryClientProvider client = { queryClient } >
190+ < Page />
191+ </ QueryClientProvider > ,
192+ )
193+
194+ expect ( markup ) . toContain ( 'status: idle' )
195+ } )
196+
197+ it ( 'useMutationState should return empty array' , ( ) => {
198+ function Page ( ) {
199+ const mutationState = useMutationState ( )
200+
201+ return < div > { `mutationState: ${ mutationState . length } ` } </ div >
202+ }
203+
204+ const markup = renderToString (
205+ < QueryClientProvider client = { queryClient } >
206+ < Page />
207+ </ QueryClientProvider > ,
208+ )
209+
210+ expect ( markup ) . toContain ( 'mutationState: 0' )
211+ } )
176212} )
You can’t perform that action at this time.
0 commit comments