@@ -367,6 +367,43 @@ describe('ngb-modal', () => {
367
367
} ) ;
368
368
} ) ;
369
369
370
+ describe ( 'beforeDismiss options' , ( ) => {
371
+
372
+ it ( 'should not dismiss when the callback returns false' , ( ) => {
373
+ const modalInstance = fixture . componentInstance . openTplDismiss ( { beforeDismiss : ( ) => { return false ; } } ) ;
374
+ fixture . detectChanges ( ) ;
375
+ expect ( fixture . nativeElement ) . toHaveModal ( ) ;
376
+
377
+ ( < HTMLElement > document . querySelector ( 'button#dismiss' ) ) . click ( ) ;
378
+ fixture . detectChanges ( ) ;
379
+ expect ( fixture . nativeElement ) . toHaveModal ( ) ;
380
+
381
+ modalInstance . close ( ) ;
382
+ fixture . detectChanges ( ) ;
383
+ expect ( fixture . nativeElement ) . not . toHaveModal ( ) ;
384
+ } ) ;
385
+
386
+ it ( 'should dimiss when the callback does not return false' , ( ) => {
387
+ fixture . componentInstance . openTplDismiss ( { beforeDismiss : ( ) => { } } ) ;
388
+ fixture . detectChanges ( ) ;
389
+ expect ( fixture . nativeElement ) . toHaveModal ( ) ;
390
+
391
+ ( < HTMLElement > document . querySelector ( 'button#dismiss' ) ) . click ( ) ;
392
+ fixture . detectChanges ( ) ;
393
+ expect ( fixture . nativeElement ) . not . toHaveModal ( ) ;
394
+ } ) ;
395
+
396
+ it ( 'should dismiss when the callback is not defined' , ( ) => {
397
+ fixture . componentInstance . openTplDismiss ( { } ) ;
398
+ fixture . detectChanges ( ) ;
399
+ expect ( fixture . nativeElement ) . toHaveModal ( ) ;
400
+
401
+ ( < HTMLElement > document . querySelector ( 'button#dismiss' ) ) . click ( ) ;
402
+ fixture . detectChanges ( ) ;
403
+ expect ( fixture . nativeElement ) . not . toHaveModal ( ) ;
404
+ } ) ;
405
+ } ) ;
406
+
370
407
describe ( 'container options' , ( ) => {
371
408
372
409
it ( 'should attach window and backdrop elements to the specified container' , ( ) => {
0 commit comments