diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index d4a5ae4e..41588cce 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -8291,6 +8291,17 @@ getJasmineRequireObj().QueueRunner = function(j$) { function QueueRunner(attrs) { this.id_ = nextid++; 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.clearStack = attrs.clearStack || diff --git a/spec/core/QueueRunnerSpec.js b/spec/core/QueueRunnerSpec.js index 847d5716..8eac83cd 100644 --- a/spec/core/QueueRunnerSpec.js +++ b/spec/core/QueueRunnerSpec.js @@ -1,4 +1,20 @@ 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() { const calls = [], queueableFn1 = { fn: jasmine.createSpy('fn1') }, diff --git a/src/core/QueueRunner.js b/src/core/QueueRunner.js index 007c5e8f..87d3ee10 100644 --- a/src/core/QueueRunner.js +++ b/src/core/QueueRunner.js @@ -37,6 +37,17 @@ getJasmineRequireObj().QueueRunner = function(j$) { function QueueRunner(attrs) { this.id_ = nextid++; 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.clearStack = attrs.clearStack ||