Removed ReportDispatcher support for multiple args and non-object args
All reporter calls take a single argument of object type, and always have.
This commit is contained in:
@@ -8581,8 +8581,8 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
|
|||||||
|
|
||||||
for (const method of dispatchedMethods) {
|
for (const method of dispatchedMethods) {
|
||||||
this[method] = (function(m) {
|
this[method] = (function(m) {
|
||||||
return function() {
|
return function(event) {
|
||||||
return dispatch(m, arguments);
|
return dispatch(m, event);
|
||||||
};
|
};
|
||||||
})(method);
|
})(method);
|
||||||
}
|
}
|
||||||
@@ -8604,13 +8604,13 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
function dispatch(method, args) {
|
function dispatch(method, event) {
|
||||||
if (reporters.length === 0 && fallbackReporter !== null) {
|
if (reporters.length === 0 && fallbackReporter !== null) {
|
||||||
reporters.push(fallbackReporter);
|
reporters.push(fallbackReporter);
|
||||||
}
|
}
|
||||||
const fns = [];
|
const fns = [];
|
||||||
for (const reporter of reporters) {
|
for (const reporter of reporters) {
|
||||||
addFn(fns, reporter, method, args);
|
addFn(fns, reporter, method, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
@@ -8630,23 +8630,23 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFn(fns, reporter, method, args) {
|
function addFn(fns, reporter, method, event) {
|
||||||
const fn = reporter[method];
|
const fn = reporter[method];
|
||||||
if (!fn) {
|
if (!fn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const thisArgs = j$.util.cloneArgs(args);
|
const thisEvent = j$.util.clone(event);
|
||||||
if (fn.length <= 1) {
|
if (fn.length <= 1) {
|
||||||
fns.push({
|
fns.push({
|
||||||
fn: function() {
|
fn: function() {
|
||||||
return fn.apply(reporter, thisArgs);
|
return fn.call(reporter, thisEvent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
fns.push({
|
fns.push({
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
return fn.apply(reporter, thisArgs.concat([done]));
|
return fn.call(reporter, thisEvent, done);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ describe('ReportDispatcher', function() {
|
|||||||
dispatcher.addReporter(reporter);
|
dispatcher.addReporter(reporter);
|
||||||
dispatcher.addReporter(anotherReporter);
|
dispatcher.addReporter(anotherReporter);
|
||||||
|
|
||||||
dispatcher.foo(123, 456);
|
dispatcher.foo({ an: 'event' });
|
||||||
|
|
||||||
expect(runQueue).toHaveBeenCalledWith(
|
expect(runQueue).toHaveBeenCalledWith(
|
||||||
jasmine.objectContaining({
|
jasmine.objectContaining({
|
||||||
@@ -37,16 +37,16 @@ describe('ReportDispatcher', function() {
|
|||||||
|
|
||||||
let fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
let fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||||
fns[0].fn();
|
fns[0].fn();
|
||||||
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
expect(reporter.foo).toHaveBeenCalledWith({ an: 'event' });
|
||||||
expect(reporter.foo.calls.mostRecent().object).toBe(reporter);
|
expect(reporter.foo.calls.mostRecent().object).toBe(reporter);
|
||||||
|
|
||||||
fns[1].fn();
|
fns[1].fn();
|
||||||
expect(anotherReporter.foo).toHaveBeenCalledWith(123, 456);
|
expect(anotherReporter.foo).toHaveBeenCalledWith({ an: 'event' });
|
||||||
expect(anotherReporter.foo.calls.mostRecent().object).toBe(anotherReporter);
|
expect(anotherReporter.foo.calls.mostRecent().object).toBe(anotherReporter);
|
||||||
|
|
||||||
runQueue.calls.reset();
|
runQueue.calls.reset();
|
||||||
|
|
||||||
dispatcher.bar('a', 'b');
|
dispatcher.bar({ another: 'event' });
|
||||||
|
|
||||||
expect(runQueue).toHaveBeenCalledWith(
|
expect(runQueue).toHaveBeenCalledWith(
|
||||||
jasmine.objectContaining({
|
jasmine.objectContaining({
|
||||||
@@ -60,10 +60,10 @@ describe('ReportDispatcher', function() {
|
|||||||
|
|
||||||
fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||||
fns[0].fn();
|
fns[0].fn();
|
||||||
expect(reporter.bar).toHaveBeenCalledWith('a', 'b');
|
expect(reporter.bar).toHaveBeenCalledWith({ another: 'event' });
|
||||||
|
|
||||||
fns[1].fn();
|
fns[1].fn();
|
||||||
expect(anotherReporter.bar).toHaveBeenCalledWith('a', 'b');
|
expect(anotherReporter.bar).toHaveBeenCalledWith({ another: 'event' });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not dispatch to a reporter if the reporter doesn't accept the method", function() {
|
it("does not dispatch to a reporter if the reporter doesn't accept the method", function() {
|
||||||
@@ -90,7 +90,7 @@ describe('ReportDispatcher', function() {
|
|||||||
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
||||||
|
|
||||||
dispatcher.provideFallbackReporter(reporter);
|
dispatcher.provideFallbackReporter(reporter);
|
||||||
dispatcher.foo(123, 456);
|
dispatcher.foo({ an: 'event' });
|
||||||
|
|
||||||
expect(runQueue).toHaveBeenCalledWith(
|
expect(runQueue).toHaveBeenCalledWith(
|
||||||
jasmine.objectContaining({
|
jasmine.objectContaining({
|
||||||
@@ -101,7 +101,7 @@ describe('ReportDispatcher', function() {
|
|||||||
|
|
||||||
const fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
const fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||||
fns[0].fn();
|
fns[0].fn();
|
||||||
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
expect(reporter.foo).toHaveBeenCalledWith({ an: 'event' });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not call fallback reporting methods when another reporter is provided', function() {
|
it('does not call fallback reporting methods when another reporter is provided', function() {
|
||||||
@@ -115,7 +115,7 @@ describe('ReportDispatcher', function() {
|
|||||||
|
|
||||||
dispatcher.provideFallbackReporter(fallbackReporter);
|
dispatcher.provideFallbackReporter(fallbackReporter);
|
||||||
dispatcher.addReporter(reporter);
|
dispatcher.addReporter(reporter);
|
||||||
dispatcher.foo(123, 456);
|
dispatcher.foo({ an: 'event' });
|
||||||
|
|
||||||
expect(runQueue).toHaveBeenCalledWith(
|
expect(runQueue).toHaveBeenCalledWith(
|
||||||
jasmine.objectContaining({
|
jasmine.objectContaining({
|
||||||
@@ -126,8 +126,8 @@ describe('ReportDispatcher', function() {
|
|||||||
|
|
||||||
const fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
const fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||||
fns[0].fn();
|
fns[0].fn();
|
||||||
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
expect(reporter.foo).toHaveBeenCalledWith({ an: 'event' });
|
||||||
expect(fallbackReporter.foo).not.toHaveBeenCalledWith(123, 456);
|
expect(fallbackReporter.foo).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows registered reporters to be cleared', function() {
|
it('allows registered reporters to be cleared', function() {
|
||||||
@@ -140,7 +140,7 @@ describe('ReportDispatcher', function() {
|
|||||||
reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']);
|
reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']);
|
||||||
|
|
||||||
dispatcher.addReporter(reporter1);
|
dispatcher.addReporter(reporter1);
|
||||||
dispatcher.foo(123);
|
dispatcher.foo({ an: 'event' });
|
||||||
expect(runQueue).toHaveBeenCalledWith(
|
expect(runQueue).toHaveBeenCalledWith(
|
||||||
jasmine.objectContaining({
|
jasmine.objectContaining({
|
||||||
queueableFns: [{ fn: jasmine.any(Function) }],
|
queueableFns: [{ fn: jasmine.any(Function) }],
|
||||||
@@ -150,11 +150,11 @@ describe('ReportDispatcher', function() {
|
|||||||
|
|
||||||
let fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
let fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||||
fns[0].fn();
|
fns[0].fn();
|
||||||
expect(reporter1.foo).toHaveBeenCalledWith(123);
|
expect(reporter1.foo).toHaveBeenCalledWith({ an: 'event' });
|
||||||
|
|
||||||
dispatcher.clearReporters();
|
dispatcher.clearReporters();
|
||||||
dispatcher.addReporter(reporter2);
|
dispatcher.addReporter(reporter2);
|
||||||
dispatcher.bar(456);
|
dispatcher.bar({ another: 'event' });
|
||||||
|
|
||||||
expect(runQueue).toHaveBeenCalledWith(
|
expect(runQueue).toHaveBeenCalledWith(
|
||||||
jasmine.objectContaining({
|
jasmine.objectContaining({
|
||||||
@@ -166,6 +166,6 @@ describe('ReportDispatcher', function() {
|
|||||||
fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
fns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||||
fns[0].fn();
|
fns[0].fn();
|
||||||
expect(reporter1.bar).not.toHaveBeenCalled();
|
expect(reporter1.bar).not.toHaveBeenCalled();
|
||||||
expect(reporter2.bar).toHaveBeenCalledWith(456);
|
expect(reporter2.bar).toHaveBeenCalledWith({ another: 'event' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
|
|||||||
|
|
||||||
for (const method of dispatchedMethods) {
|
for (const method of dispatchedMethods) {
|
||||||
this[method] = (function(m) {
|
this[method] = (function(m) {
|
||||||
return function() {
|
return function(event) {
|
||||||
return dispatch(m, arguments);
|
return dispatch(m, event);
|
||||||
};
|
};
|
||||||
})(method);
|
})(method);
|
||||||
}
|
}
|
||||||
@@ -29,13 +29,13 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
function dispatch(method, args) {
|
function dispatch(method, event) {
|
||||||
if (reporters.length === 0 && fallbackReporter !== null) {
|
if (reporters.length === 0 && fallbackReporter !== null) {
|
||||||
reporters.push(fallbackReporter);
|
reporters.push(fallbackReporter);
|
||||||
}
|
}
|
||||||
const fns = [];
|
const fns = [];
|
||||||
for (const reporter of reporters) {
|
for (const reporter of reporters) {
|
||||||
addFn(fns, reporter, method, args);
|
addFn(fns, reporter, method, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
@@ -55,23 +55,23 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFn(fns, reporter, method, args) {
|
function addFn(fns, reporter, method, event) {
|
||||||
const fn = reporter[method];
|
const fn = reporter[method];
|
||||||
if (!fn) {
|
if (!fn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const thisArgs = j$.util.cloneArgs(args);
|
const thisEvent = j$.util.clone(event);
|
||||||
if (fn.length <= 1) {
|
if (fn.length <= 1) {
|
||||||
fns.push({
|
fns.push({
|
||||||
fn: function() {
|
fn: function() {
|
||||||
return fn.apply(reporter, thisArgs);
|
return fn.call(reporter, thisEvent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
fns.push({
|
fns.push({
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
return fn.apply(reporter, thisArgs.concat([done]));
|
return fn.call(reporter, thisEvent, done);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user