-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for registration of multiple Reporter with Jasmine.
- Loading branch information
Christian Williams
committed
Jul 9, 2009
1 parent
521f839
commit a6aa9c6
Showing
7 changed files
with
98 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
describe("MultiReporter", function() { | ||
it("should delegate to any and all subreporters", function() { | ||
var multiReporter = new jasmine.MultiReporter(); | ||
var fakeReporter1 = jasmine.createSpyObj("fakeReporter1", ["reportSpecResults"]); | ||
var fakeReporter2 = jasmine.createSpyObj("fakeReporter2", ["reportSpecResults"]); | ||
multiReporter.addReporter(fakeReporter1); | ||
multiReporter.addReporter(fakeReporter2); | ||
|
||
multiReporter.reportSpecResults('blah', 'foo'); | ||
expect(fakeReporter1.reportSpecResults).wasCalledWith('blah', 'foo'); | ||
expect(fakeReporter2.reportSpecResults).wasCalledWith('blah', 'foo'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @constructor | ||
*/ | ||
jasmine.MultiReporter = function() { | ||
this.subReporters_ = []; | ||
}; | ||
|
||
jasmine.MultiReporter.prototype.addReporter = function(reporter) { | ||
this.subReporters_.push(reporter); | ||
}; | ||
|
||
(function() { | ||
var functionNames = ["reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"]; | ||
for (var i = 0; i < functionNames.length; i++) { | ||
var functionName = functionNames[i]; | ||
jasmine.MultiReporter.prototype[functionName] = (function(functionName) { | ||
return function() { | ||
for (var j = 0; j < this.subReporters_.length; j++) { | ||
this.subReporters_[j][functionName].apply(this.subReporters_[j], arguments); | ||
} | ||
}; | ||
})(functionName); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters