File tree Expand file tree Collapse file tree
packages/angular-query-experimental/src/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -518,6 +518,21 @@ describe('injectMutation', () => {
518518 await expect ( ( ) => mutateAsync ( ) ) . rejects . toThrow ( err )
519519 } )
520520
521+ it ( 'should resolve mutateAsync with the value returned from mutationFn' , async ( ) => {
522+ const key = queryKey ( )
523+ const { mutateAsync } = TestBed . runInInjectionContext ( ( ) => {
524+ return injectMutation ( ( ) => ( {
525+ mutationKey : key ,
526+ mutationFn : ( params : string ) => sleep ( 10 ) . then ( ( ) => params ) ,
527+ } ) )
528+ } )
529+
530+ const promise = mutateAsync ( 'Mock data' )
531+ await vi . advanceTimersByTimeAsync ( 11 )
532+
533+ await expect ( promise ) . resolves . toBe ( 'Mock data' )
534+ } )
535+
521536 describe ( 'injection context' , ( ) => {
522537 it ( 'should throw NG0203 with descriptive error outside injection context' , ( ) => {
523538 const key = queryKey ( )
You can’t perform that action at this time.
0 commit comments