Validate queueableFns
This commit is contained in:
@@ -8291,6 +8291,17 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
function QueueRunner(attrs) {
|
function QueueRunner(attrs) {
|
||||||
this.id_ = nextid++;
|
this.id_ = nextid++;
|
||||||
this.queueableFns = attrs.queueableFns || [];
|
this.queueableFns = attrs.queueableFns || [];
|
||||||
|
|
||||||
|
for (const f of this.queueableFns) {
|
||||||
|
if (!f) {
|
||||||
|
throw new Error('Received a falsy queueableFn');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!f.fn) {
|
||||||
|
throw new Error('Received a queueableFn with no fn');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.onComplete = attrs.onComplete || emptyFn;
|
this.onComplete = attrs.onComplete || emptyFn;
|
||||||
this.clearStack =
|
this.clearStack =
|
||||||
attrs.clearStack ||
|
attrs.clearStack ||
|
||||||
|
|||||||
@@ -1,4 +1,20 @@
|
|||||||
describe('QueueRunner', function() {
|
describe('QueueRunner', function() {
|
||||||
|
it('validates that queueableFns are truthy', function() {
|
||||||
|
expect(function() {
|
||||||
|
new jasmineUnderTest.QueueRunner({
|
||||||
|
queueableFns: [undefined]
|
||||||
|
});
|
||||||
|
}).toThrowError('Received a falsy queueableFn');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('validates that queueableFns have fn properties', function() {
|
||||||
|
expect(function() {
|
||||||
|
new jasmineUnderTest.QueueRunner({
|
||||||
|
queueableFns: [{ fn: undefined }]
|
||||||
|
});
|
||||||
|
}).toThrowError('Received a queueableFn with no fn');
|
||||||
|
});
|
||||||
|
|
||||||
it("runs all the functions it's passed", function() {
|
it("runs all the functions it's passed", function() {
|
||||||
const calls = [],
|
const calls = [],
|
||||||
queueableFn1 = { fn: jasmine.createSpy('fn1') },
|
queueableFn1 = { fn: jasmine.createSpy('fn1') },
|
||||||
|
|||||||
@@ -37,6 +37,17 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
function QueueRunner(attrs) {
|
function QueueRunner(attrs) {
|
||||||
this.id_ = nextid++;
|
this.id_ = nextid++;
|
||||||
this.queueableFns = attrs.queueableFns || [];
|
this.queueableFns = attrs.queueableFns || [];
|
||||||
|
|
||||||
|
for (const f of this.queueableFns) {
|
||||||
|
if (!f) {
|
||||||
|
throw new Error('Received a falsy queueableFn');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!f.fn) {
|
||||||
|
throw new Error('Received a queueableFn with no fn');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.onComplete = attrs.onComplete || emptyFn;
|
this.onComplete = attrs.onComplete || emptyFn;
|
||||||
this.clearStack =
|
this.clearStack =
|
||||||
attrs.clearStack ||
|
attrs.clearStack ||
|
||||||
|
|||||||
Reference in New Issue
Block a user