Allow currently registered reporters to be cleared
- jasmine/jasmine-npm#88
This commit is contained in:
@@ -792,6 +792,10 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
reporter.provideFallbackReporter(reporterToAdd);
|
||||
};
|
||||
|
||||
this.clearReporters = function() {
|
||||
reporter.clearReporters();
|
||||
};
|
||||
|
||||
var spyRegistry = new j$.SpyRegistry({currentSpies: function() {
|
||||
if(!currentRunnable()) {
|
||||
throw new Error('Spies must be created in a before function or a spec');
|
||||
@@ -2017,11 +2021,14 @@ getJasmineRequireObj().ReportDispatcher = function() {
|
||||
this.addReporter = function(reporter) {
|
||||
reporters.push(reporter);
|
||||
};
|
||||
|
||||
|
||||
this.provideFallbackReporter = function(reporter) {
|
||||
fallbackReporter = reporter;
|
||||
};
|
||||
|
||||
this.clearReporters = function() {
|
||||
reporters = [];
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ describe("ReportDispatcher", function() {
|
||||
dispatcher.provideFallbackReporter(reporter);
|
||||
dispatcher.foo(123, 456);
|
||||
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
||||
|
||||
});
|
||||
|
||||
it("does not call fallback reporting methods when another report is provided", function() {
|
||||
@@ -59,6 +58,22 @@ describe("ReportDispatcher", function() {
|
||||
|
||||
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
||||
expect(fallbackReporter.foo).not.toHaveBeenCalledWith(123, 456);
|
||||
});
|
||||
|
||||
it("allows registered reporters to be cleared", function() {
|
||||
var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar']),
|
||||
reporter1 = jasmine.createSpyObj('reporter1', ['foo', 'bar']),
|
||||
reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']);
|
||||
|
||||
dispatcher.addReporter(reporter1);
|
||||
dispatcher.foo(123);
|
||||
expect(reporter1.foo).toHaveBeenCalledWith(123);
|
||||
|
||||
dispatcher.clearReporters();
|
||||
dispatcher.addReporter(reporter2);
|
||||
dispatcher.bar(456);
|
||||
|
||||
expect(reporter1.bar).not.toHaveBeenCalled();
|
||||
expect(reporter2.bar).toHaveBeenCalledWith(456);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -278,6 +278,10 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
reporter.provideFallbackReporter(reporterToAdd);
|
||||
};
|
||||
|
||||
this.clearReporters = function() {
|
||||
reporter.clearReporters();
|
||||
};
|
||||
|
||||
var spyRegistry = new j$.SpyRegistry({currentSpies: function() {
|
||||
if(!currentRunnable()) {
|
||||
throw new Error('Spies must be created in a before function or a spec');
|
||||
|
||||
@@ -18,11 +18,14 @@ getJasmineRequireObj().ReportDispatcher = function() {
|
||||
this.addReporter = function(reporter) {
|
||||
reporters.push(reporter);
|
||||
};
|
||||
|
||||
|
||||
this.provideFallbackReporter = function(reporter) {
|
||||
fallbackReporter = reporter;
|
||||
};
|
||||
|
||||
this.clearReporters = function() {
|
||||
reporters = [];
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user