@@ -384,10 +384,13 @@ describe('useCreateResourceMutation', () => {
384384 value : 73.5 ,
385385 } ,
386386 } ;
387- await act ( async ( ) => {
388- await result . current . mutateAsync ( observation ) ;
387+ act ( ( ) => {
388+ result . current . mutateAsync ( observation ) ;
389389 } ) ;
390390
391+ await waitFor ( ( ) => {
392+ expect ( result . current . data ) . toEqual ( resultBundle ) ;
393+ } ) ;
391394 expect ( axiosMock . history . post [ 0 ] . url ) . toBe ( '/v1/fhir/dstu3/Observation' ) ;
392395 expect ( JSON . parse ( axiosMock . history . post [ 0 ] . data ) ) . toEqual ( {
393396 ...observation ,
@@ -403,9 +406,6 @@ describe('useCreateResourceMutation', () => {
403406 ] ,
404407 } ,
405408 } ) ;
406- await waitFor ( ( ) => {
407- expect ( result . current . data ) . toEqual ( resultBundle ) ;
408- } ) ;
409409 } ) ;
410410} ) ;
411411
@@ -462,10 +462,13 @@ describe('useUpsertMutation', () => {
462462 value : 1.8 ,
463463 } ,
464464 } ;
465- await act ( async ( ) => {
466- await result . current . mutateAsync ( [ observation1 , observation2 ] ) ;
465+ act ( ( ) => {
466+ result . current . mutateAsync ( [ observation1 , observation2 ] ) ;
467467 } ) ;
468468
469+ await waitFor ( ( ) => {
470+ expect ( result . current . data ) . toEqual ( resultBundle ) ;
471+ } ) ;
469472 expect ( axiosMock . history . post [ 0 ] . url ) . toBe (
470473 'https://fhir.us.lifeomic.com/acct1/dstu3' ,
471474 ) ;
@@ -511,9 +514,6 @@ describe('useUpsertMutation', () => {
511514 } ,
512515 ] ,
513516 } ) ;
514- await waitFor ( ( ) => {
515- expect ( result . current . data ) . toEqual ( resultBundle ) ;
516- } ) ;
517517 } ) ;
518518} ) ;
519519
@@ -529,19 +529,17 @@ describe('useDeleteResourceMutation', () => {
529529 return useDeleteResourceMutation ( ) ;
530530 }
531531 const { result } = renderHookInContext ( useTestHook ) ;
532- await act ( async ( ) => {
533- await result . current . mutateAsync ( {
532+ act ( ( ) => {
533+ result . current . mutateAsync ( {
534534 id : observationId ,
535535 resourceType : 'Observation' ,
536536 } ) ;
537537 } ) ;
538538
539- await act ( async ( ) => {
540- await waitFor ( ( ) => {
541- expect ( axiosMock . history . delete [ 0 ] . url ) . toBe (
542- `/v1/fhir/dstu3/Observation/${ observationId } ` ,
543- ) ;
544- } ) ;
539+ await waitFor ( ( ) => {
540+ expect ( axiosMock . history . delete [ 0 ] . url ) . toBe (
541+ `/v1/fhir/dstu3/Observation/${ observationId } ` ,
542+ ) ;
545543 } ) ;
546544 } ) ;
547545} ) ;
0 commit comments