Validate queueableFns

This commit is contained in:
Steve Gravrock
2025-08-23 09:03:38 -07:00
parent 8d99f27be8
commit f94d0ceda9
3 changed files with 38 additions and 0 deletions

View File

@@ -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 ||

View File

@@ -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') },

View File

@@ -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 ||