Skip to content

Commit 36f90e8

Browse files
committed
Added specs for existing behavior of Jasmine#onComplete
1 parent 20e11b2 commit 36f90e8

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

spec/jasmine_spec.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ describe('Jasmine', function() {
515515
});
516516
});
517517

518-
describe('default completion behavior', function() {
518+
describe('completion behavior', function() {
519519
beforeEach(function() {
520520
this.runWithOverallStatus = async function(overallStatus) {
521521
const reporters = [];
@@ -546,14 +546,38 @@ describe('Jasmine', function() {
546546
}
547547
});
548548

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+
});
552559
});
553560

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+
});
557581
});
558582
});
559583
});

0 commit comments

Comments
 (0)