2009-07-09 01:18:17 +00:00
|
|
|
describe("jasmine.MultiReporter", function() {
|
2009-07-09 01:33:15 +00:00
|
|
|
var multiReporter, fakeReporter1, fakeReporter2;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
multiReporter = new jasmine.MultiReporter();
|
|
|
|
fakeReporter1 = jasmine.createSpyObj("fakeReporter1", ["reportSpecResults"]);
|
|
|
|
fakeReporter2 = jasmine.createSpyObj("fakeReporter2", ["reportSpecResults", "reportRunnerStarting"]);
|
2009-07-09 00:55:25 +00:00
|
|
|
multiReporter.addReporter(fakeReporter1);
|
|
|
|
multiReporter.addReporter(fakeReporter2);
|
2009-07-09 01:33:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should support all the method calls that jasmine.Reporter supports", function() {
|
2010-06-24 18:10:58 +00:00
|
|
|
var delegate = {};
|
|
|
|
multiReporter.addReporter(delegate);
|
|
|
|
|
|
|
|
this.addMatchers({
|
|
|
|
toDelegateMethod: function(methodName) {
|
|
|
|
delegate[methodName] = jasmine.createSpy(methodName);
|
|
|
|
this.actual[methodName]("whatever argument");
|
|
|
|
|
2011-02-26 23:07:59 +00:00
|
|
|
return delegate[methodName].wasCalled &&
|
|
|
|
delegate[methodName].mostRecentCall.args.length == 1 &&
|
|
|
|
delegate[methodName].mostRecentCall.args[0] == "whatever argument";
|
2010-06-24 18:10:58 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(multiReporter).toDelegateMethod('reportRunnerStarting');
|
|
|
|
expect(multiReporter).toDelegateMethod('reportRunnerResults');
|
|
|
|
expect(multiReporter).toDelegateMethod('reportSuiteResults');
|
|
|
|
expect(multiReporter).toDelegateMethod('reportSpecStarting');
|
|
|
|
expect(multiReporter).toDelegateMethod('reportSpecResults');
|
|
|
|
expect(multiReporter).toDelegateMethod('log');
|
2009-07-09 01:33:15 +00:00
|
|
|
});
|
2009-07-09 00:55:25 +00:00
|
|
|
|
2009-07-09 01:33:15 +00:00
|
|
|
it("should delegate to any and all subreporters", function() {
|
2009-07-09 00:55:25 +00:00
|
|
|
multiReporter.reportSpecResults('blah', 'foo');
|
2010-06-24 17:34:03 +00:00
|
|
|
expect(fakeReporter1.reportSpecResults).toHaveBeenCalledWith('blah', 'foo');
|
|
|
|
expect(fakeReporter2.reportSpecResults).toHaveBeenCalledWith('blah', 'foo');
|
2009-07-09 00:55:25 +00:00
|
|
|
});
|
2009-07-09 01:33:15 +00:00
|
|
|
|
|
|
|
it("should quietly skip delegating to any subreporters which lack the given method", function() {
|
|
|
|
multiReporter.reportRunnerStarting('blah', 'foo');
|
2010-06-24 17:34:03 +00:00
|
|
|
expect(fakeReporter2.reportRunnerStarting).toHaveBeenCalledWith('blah', 'foo');
|
2009-07-09 01:33:15 +00:00
|
|
|
});
|
2009-07-09 00:55:25 +00:00
|
|
|
});
|