Skip to content

Commit

Permalink
Call the 'onComplete' method when done executing the specs.
Browse files Browse the repository at this point in the history
Fixes #119
Fixes #123
  • Loading branch information
theycallmeswift authored and mhevery committed Feb 15, 2012
1 parent 31146e0 commit 6200381
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/jasmine-node/reporter.js
Expand Up @@ -37,6 +37,8 @@
this.started_ = false;
this.finished_ = false;

this.callback_ = config.onComplete || false

this.suites_ = [];
this.specResults_ = {};
this.failures_ = [];
Expand Down Expand Up @@ -105,6 +107,7 @@
this.printLine_(this.stringWithColor_(this.printRunnerResults_(runner), resultColor));

this.finished_ = true;
if(this.callback_) { this.callback_(runner); }
},

reportFailures_: function() {
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -15,6 +15,7 @@
, "Matteo Collina <matteo.collina@gmail.com>"
]
, "maintainers" : "Martin Häger <martin.haeger@gmail.com>"
, "contributors" : [ "Mike Swift <theycallmeswift@gmail.com> (http://theycallmeswift.com)" ]
, "licenses" : ["MIT"]
, "dependencies" : { "coffee-script" : ">=1.0.1"
, "jasmine-reporters" : "0.1.0"
Expand Down
16 changes: 16 additions & 0 deletions spec/reporter_spec.js
Expand Up @@ -48,6 +48,19 @@ describe('TerminalReporter', function() {
this.reporter = new jasmineNode.TerminalReporter(config);
expect(this.reporter.failures_.length).toEqual(0);
});

it('sets the callback_ property to false by default', function() {
var config = {}
this.reporter = new jasmineNode.TerminalReporter(config);
expect(this.reporter.callback_).toEqual(false)
});

it('sets the callback_ property to onComplete if supplied', function() {
var foo = function() { }
var config = { onComplete: foo }
this.reporter = new jasmineNode.TerminalReporter(config);
expect(this.reporter.callback_).toBe(foo)
});
});

describe('when the report runner starts', function() {
Expand Down Expand Up @@ -124,6 +137,8 @@ describe('TerminalReporter', function() {
var printRunnerResultsSpy = spyOn(this.reporter, 'printRunnerResults_').
andReturn('this is the runner result');

var callbackSpy = spyOn(this.reporter, 'callback_');

var runner = {
results: function() {
var result = { failedCount: 0 };
Expand All @@ -137,6 +152,7 @@ describe('TerminalReporter', function() {

expect(failuresSpy).toHaveBeenCalled();
expect(this.printLineSpy).toHaveBeenCalled();
expect(callbackSpy).toHaveBeenCalled();
});
});

Expand Down

0 comments on commit 6200381

Please sign in to comment.