@@ -350,8 +350,8 @@ describe( 'Confirm', () => {
350350 expect ( onConfirm ) . toHaveBeenCalled ( ) ;
351351 } ) ;
352352
353- it ( 'should set confirm button busy and disable both buttons when `isBusy` is true ' , ( ) => {
354- render (
353+ it ( 'should handle `isBusy` prop with different combinations ' , ( ) => {
354+ const { rerender } = render (
355355 < ConfirmDialog
356356 isOpen
357357 onConfirm = { noop }
@@ -362,10 +362,10 @@ describe( 'Confirm', () => {
362362 </ ConfirmDialog >
363363 ) ;
364364
365- const cancelButton = screen . getByRole ( 'button' , {
365+ let cancelButton = screen . getByRole ( 'button' , {
366366 name : 'Cancel' ,
367367 } ) ;
368- const confirmButton = screen . getByRole ( 'button' , { name : 'OK' } ) ;
368+ let confirmButton = screen . getByRole ( 'button' , { name : 'OK' } ) ;
369369
370370 // Only confirm button shows busy spinner
371371 expect ( cancelButton ) . not . toHaveClass ( 'is-busy' ) ;
@@ -375,10 +375,9 @@ describe( 'Confirm', () => {
375375 // Intentionally rely on aria-disabled rather than disabled attribute
376376 expect ( cancelButton ) . toHaveAttribute ( 'aria-disabled' , 'true' ) ;
377377 expect ( confirmButton ) . toHaveAttribute ( 'aria-disabled' , 'true' ) ;
378- } ) ;
379378
380- it ( 'should not set busy and should keep buttons enabled when ` isBusy` is false' , ( ) => {
381- render (
379+ // Test when isBusy is false
380+ rerender (
382381 < ConfirmDialog
383382 isOpen
384383 onConfirm = { noop }
@@ -389,28 +388,27 @@ describe( 'Confirm', () => {
389388 </ ConfirmDialog >
390389 ) ;
391390
392- const cancelButton = screen . getByRole ( 'button' , {
391+ cancelButton = screen . getByRole ( 'button' , {
393392 name : 'Cancel' ,
394393 } ) ;
395- const confirmButton = screen . getByRole ( 'button' , { name : 'OK' } ) ;
394+ confirmButton = screen . getByRole ( 'button' , { name : 'OK' } ) ;
396395
397396 expect ( cancelButton ) . not . toHaveClass ( 'is-busy' ) ;
398397 expect ( confirmButton ) . not . toHaveClass ( 'is-busy' ) ;
399398 expect ( cancelButton ) . toBeEnabled ( ) ;
400399 expect ( confirmButton ) . toBeEnabled ( ) ;
401- } ) ;
402400
403- it ( 'should not set busy and should keep buttons enabled when ` isBusy` is undefined' , ( ) => {
404- render (
401+ // Test when isBusy is undefined
402+ rerender (
405403 < ConfirmDialog isOpen onConfirm = { noop } onCancel = { noop } >
406404 Are you sure?
407405 </ ConfirmDialog >
408406 ) ;
409407
410- const cancelButton = screen . getByRole ( 'button' , {
408+ cancelButton = screen . getByRole ( 'button' , {
411409 name : 'Cancel' ,
412410 } ) ;
413- const confirmButton = screen . getByRole ( 'button' , { name : 'OK' } ) ;
411+ confirmButton = screen . getByRole ( 'button' , { name : 'OK' } ) ;
414412
415413 expect ( cancelButton ) . not . toHaveClass ( 'is-busy' ) ;
416414 expect ( confirmButton ) . not . toHaveClass ( 'is-busy' ) ;
0 commit comments