File tree Expand file tree Collapse file tree 1 file changed +16
-14
lines changed
packages/angular-query-experimental/src/__tests__ Expand file tree Collapse file tree 1 file changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -28,24 +28,26 @@ describe('injectIsMutating', () => {
28
28
vi . useRealTimers ( )
29
29
} )
30
30
31
- test ( 'should properly return isMutating state' , ( ) => {
32
- TestBed . runInInjectionContext ( ( ) => {
33
- const isMutating = injectIsMutating ( )
34
- const mutation = injectMutation ( ( ) => ( {
31
+ test ( 'should properly return isMutating state' , async ( ) => {
32
+ const [ mutation , isMutating ] = TestBed . runInInjectionContext ( ( ) => [
33
+ injectMutation ( ( ) => ( {
35
34
mutationKey : [ 'isMutating1' ] ,
36
- mutationFn : ( params : { par1 : string } ) => sleep ( 0 ) . then ( ( ) => params ) ,
37
- } ) )
35
+ mutationFn : ( params : { par1 : string } ) => sleep ( 10 ) . then ( ( ) => params ) ,
36
+ } ) ) ,
37
+ injectIsMutating ( ) ,
38
+ ] )
38
39
39
- expect ( isMutating ( ) ) . toBe ( 0 )
40
+ expect ( isMutating ( ) ) . toBe ( 0 )
40
41
41
- mutation . mutate ( {
42
- par1 : 'par1' ,
43
- } )
44
-
45
- vi . advanceTimersByTime ( 1 )
46
-
47
- expect ( isMutating ( ) ) . toBe ( 1 )
42
+ mutation . mutate ( {
43
+ par1 : 'par1' ,
48
44
} )
45
+
46
+ expect ( isMutating ( ) ) . toBe ( 0 )
47
+ await vi . advanceTimersByTimeAsync ( 0 )
48
+ expect ( isMutating ( ) ) . toBe ( 1 )
49
+ await vi . advanceTimersByTimeAsync ( 11 )
50
+ expect ( isMutating ( ) ) . toBe ( 0 )
49
51
} )
50
52
51
53
describe ( 'injection context' , ( ) => {
You can’t perform that action at this time.
0 commit comments