@@ -515,7 +515,7 @@ describe('Jasmine', function() {
515
515
} ) ;
516
516
} ) ;
517
517
518
- describe ( 'default completion behavior' , function ( ) {
518
+ describe ( 'completion behavior' , function ( ) {
519
519
beforeEach ( function ( ) {
520
520
this . runWithOverallStatus = async function ( overallStatus ) {
521
521
const reporters = [ ] ;
@@ -546,14 +546,38 @@ describe('Jasmine', function() {
546
546
}
547
547
} ) ;
548
548
549
- it ( 'exits successfully when the whole suite is green' , async function ( ) {
550
- await this . runWithOverallStatus ( 'passed' ) ;
551
- expect ( this . testJasmine . exit ) . toHaveBeenCalledWith ( 0 ) ;
549
+ describe ( 'default' , function ( ) {
550
+ it ( 'exits successfully when the whole suite is green' , async function ( ) {
551
+ await this . runWithOverallStatus ( 'passed' ) ;
552
+ expect ( this . testJasmine . exit ) . toHaveBeenCalledWith ( 0 ) ;
553
+ } ) ;
554
+
555
+ it ( 'exits with a failure when anything in the suite is not green' , async function ( ) {
556
+ await this . runWithOverallStatus ( 'failed' ) ;
557
+ expect ( this . testJasmine . exit ) . toHaveBeenCalledWith ( 1 ) ;
558
+ } ) ;
552
559
} ) ;
553
560
554
- it ( 'exits with a failure when anything in the suite is not green' , async function ( ) {
555
- await this . runWithOverallStatus ( 'failed' ) ;
556
- expect ( this . testJasmine . exit ) . toHaveBeenCalledWith ( 1 ) ;
561
+ describe ( 'When #onComplete has been called' , function ( ) {
562
+ it ( 'does not exit' , async function ( ) {
563
+ this . testJasmine . onComplete ( function ( ) { } ) ;
564
+ await this . runWithOverallStatus ( 'anything' ) ;
565
+ expect ( this . testJasmine . exit ) . not . toHaveBeenCalled ( ) ;
566
+ } ) ;
567
+
568
+ it ( 'calls the supplied completion handler with true when the whole suite is green' , async function ( ) {
569
+ const completionHandler = jasmine . createSpy ( 'completionHandler' ) ;
570
+ this . testJasmine . onComplete ( completionHandler ) ;
571
+ await this . runWithOverallStatus ( 'passed' ) ;
572
+ expect ( completionHandler ) . toHaveBeenCalledWith ( true ) ;
573
+ } ) ;
574
+
575
+ it ( 'calls the supplied completion handler with false when anything in the suite is not green' , async function ( ) {
576
+ const completionHandler = jasmine . createSpy ( 'completionHandler' ) ;
577
+ this . testJasmine . onComplete ( completionHandler ) ;
578
+ await this . runWithOverallStatus ( 'failed' ) ;
579
+ expect ( completionHandler ) . toHaveBeenCalledWith ( false ) ;
580
+ } ) ;
557
581
} ) ;
558
582
} ) ;
559
583
} ) ;
0 commit comments