@@ -420,15 +420,31 @@ describe('useEditController', () => {
420420 mutationMode = "pessimistic"
421421 mutationOptions = { { onSuccess } }
422422 >
423- { ( { save } ) => {
423+ { ( { record , save } ) => {
424424 saveCallback = save ;
425- return < div / >;
425+ return < div > { record ?. id } </ div > ;
426426 } }
427427 </ EditController >
428428 </ CoreAdminContext >
429429 ) ;
430+ await screen . findByText ( '12' ) ;
430431 await act ( async ( ) => saveCallback ( { foo : 'bar' } ) ) ;
431- await waitFor ( ( ) => expect ( onSuccess ) . toHaveBeenCalled ( ) ) ;
432+ await waitFor ( ( ) =>
433+ expect ( onSuccess ) . toHaveBeenCalledWith (
434+ {
435+ id : 12 ,
436+ foo : 'bar' ,
437+ } ,
438+ {
439+ id : 12 ,
440+ data : { foo : 'bar' } ,
441+ previousData : { id : 12 } ,
442+ resource : 'posts' ,
443+ meta : undefined ,
444+ } ,
445+ { snapshot : expect . any ( Array ) }
446+ )
447+ ) ;
432448 expect ( notificationsSpy ) . toEqual ( [ ] ) ;
433449 } ) ;
434450
@@ -458,15 +474,31 @@ describe('useEditController', () => {
458474 mutationMode = "optimistic"
459475 mutationOptions = { { onSuccess } }
460476 >
461- { ( { save } ) => {
477+ { ( { record , save } ) => {
462478 saveCallback = save ;
463- return < div / >;
479+ return < div > { record ?. id } </ div > ;
464480 } }
465481 </ EditController >
466482 </ CoreAdminContext >
467483 ) ;
484+ await screen . findByText ( '12' ) ;
468485 await act ( async ( ) => saveCallback ( { foo : 'bar' } ) ) ;
469- await waitFor ( ( ) => expect ( onSuccess ) . toHaveBeenCalled ( ) ) ;
486+ await waitFor ( ( ) =>
487+ expect ( onSuccess ) . toHaveBeenCalledWith (
488+ {
489+ id : 12 ,
490+ foo : 'bar' ,
491+ } ,
492+ {
493+ id : 12 ,
494+ data : { foo : 'bar' } ,
495+ previousData : { id : 12 } ,
496+ resource : 'posts' ,
497+ meta : undefined ,
498+ } ,
499+ { snapshot : expect . any ( Array ) }
500+ )
501+ ) ;
470502 expect ( notificationsSpy ) . toEqual ( [ ] ) ;
471503 } ) ;
472504
@@ -495,15 +527,31 @@ describe('useEditController', () => {
495527 { ...defaultProps }
496528 mutationOptions = { { onSuccess } }
497529 >
498- { ( { save } ) => {
530+ { ( { record , save } ) => {
499531 saveCallback = save ;
500- return < div / >;
532+ return < div > { record ?. id } </ div > ;
501533 } }
502534 </ EditController >
503535 </ CoreAdminContext >
504536 ) ;
537+ await screen . findByText ( '12' ) ;
505538 await act ( async ( ) => saveCallback ( { foo : 'bar' } ) ) ;
506- await waitFor ( ( ) => expect ( onSuccess ) . toHaveBeenCalled ( ) ) ;
539+ await waitFor ( ( ) =>
540+ expect ( onSuccess ) . toHaveBeenCalledWith (
541+ {
542+ id : 12 ,
543+ foo : 'bar' ,
544+ } ,
545+ {
546+ id : 12 ,
547+ data : { foo : 'bar' } ,
548+ previousData : { id : 12 } ,
549+ resource : 'posts' ,
550+ meta : undefined ,
551+ } ,
552+ { snapshot : expect . any ( Array ) }
553+ )
554+ ) ;
507555 expect ( notificationsSpy ) . toEqual ( [ ] ) ;
508556 } ) ;
509557
0 commit comments