Pass queue runner factory to Spec#execute, not ctor
This commit is contained in:
@@ -718,7 +718,6 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
this.onLateError = attrs.onLateError || function() {};
|
this.onLateError = attrs.onLateError || function() {};
|
||||||
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
|
|
||||||
this.catchingExceptions =
|
this.catchingExceptions =
|
||||||
attrs.catchingExceptions ||
|
attrs.catchingExceptions ||
|
||||||
function() {
|
function() {
|
||||||
@@ -792,7 +791,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
return this.asyncExpectationFactory(actual, this);
|
return this.asyncExpectationFactory(actual, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
Spec.prototype.execute = function(onComplete, excluded, failSpecWithNoExp) {
|
Spec.prototype.execute = function(queueRunnerFactory, onComplete, excluded, failSpecWithNoExp) {
|
||||||
const onStart = {
|
const onStart = {
|
||||||
fn: done => {
|
fn: done => {
|
||||||
this.timer.start();
|
this.timer.start();
|
||||||
@@ -854,7 +853,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
runnerConfig.queueableFns.unshift(onStart);
|
runnerConfig.queueableFns.unshift(onStart);
|
||||||
runnerConfig.queueableFns.push(complete);
|
runnerConfig.queueableFns.push(complete);
|
||||||
|
|
||||||
this.queueRunnerFactory(runnerConfig);
|
queueRunnerFactory(runnerConfig);
|
||||||
};
|
};
|
||||||
|
|
||||||
Spec.prototype.reset = function() {
|
Spec.prototype.reset = function() {
|
||||||
@@ -1462,7 +1461,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
deprecator.addDeprecationWarning(runable, deprecation, options);
|
deprecator.addDeprecationWarning(runable, deprecation, options);
|
||||||
};
|
};
|
||||||
|
|
||||||
function queueRunnerFactory(options, args) {
|
function queueRunnerFactory(options) {
|
||||||
if (options.isLeaf) {
|
if (options.isLeaf) {
|
||||||
// A spec
|
// A spec
|
||||||
options.SkipPolicy = j$.CompleteOnFirstErrorSkipPolicy;
|
options.SkipPolicy = j$.CompleteOnFirstErrorSkipPolicy;
|
||||||
@@ -1492,7 +1491,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
};
|
};
|
||||||
options.deprecated = self.deprecated;
|
options.deprecated = self.deprecated;
|
||||||
|
|
||||||
new j$.QueueRunner(options).execute(args);
|
new j$.QueueRunner(options).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
const suiteBuilder = new j$.SuiteBuilder({
|
const suiteBuilder = new j$.SuiteBuilder({
|
||||||
@@ -9649,7 +9648,6 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
|||||||
this.onLateError_ = options.onLateError;
|
this.onLateError_ = options.onLateError;
|
||||||
this.specResultCallback_ = options.specResultCallback;
|
this.specResultCallback_ = options.specResultCallback;
|
||||||
this.specStarted_ = options.specStarted;
|
this.specStarted_ = options.specStarted;
|
||||||
this.queueRunnerFactory_ = options.queueRunnerFactory;
|
|
||||||
|
|
||||||
this.nextSuiteId_ = 0;
|
this.nextSuiteId_ = 0;
|
||||||
this.nextSpecId_ = 0;
|
this.nextSpecId_ = 0;
|
||||||
@@ -9849,7 +9847,6 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
|||||||
},
|
},
|
||||||
onStart: (spec, next) => this.specStarted_(spec, suite, next),
|
onStart: (spec, next) => this.specStarted_(spec, suite, next),
|
||||||
description: description,
|
description: description,
|
||||||
queueRunnerFactory: this.queueRunnerFactory_,
|
|
||||||
userContext: function() {
|
userContext: function() {
|
||||||
return suite.clonedSharedUserContext();
|
return suite.clonedSharedUserContext();
|
||||||
},
|
},
|
||||||
@@ -10197,6 +10194,7 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|||||||
return {
|
return {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
node.execute(
|
node.execute(
|
||||||
|
queueRunnerFactory,
|
||||||
done,
|
done,
|
||||||
stats[node.id].excluded,
|
stats[node.id].excluded,
|
||||||
failSpecWithNoExpectations
|
failSpecWithNoExpectations
|
||||||
|
|||||||
@@ -38,11 +38,10 @@ describe('Spec', function() {
|
|||||||
spec = new jasmineUnderTest.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
description: 'my test',
|
description: 'my test',
|
||||||
id: 'some-id',
|
id: 'some-id',
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} }
|
||||||
queueRunnerFactory: fakeQueueRunner
|
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.execute();
|
spec.execute(fakeQueueRunner);
|
||||||
|
|
||||||
expect(fakeQueueRunner).toHaveBeenCalled();
|
expect(fakeQueueRunner).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@@ -54,11 +53,10 @@ describe('Spec', function() {
|
|||||||
id: 123,
|
id: 123,
|
||||||
description: 'foo bar',
|
description: 'foo bar',
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
onStart: startCallback,
|
onStart: startCallback
|
||||||
queueRunnerFactory: fakeQueueRunner
|
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.execute();
|
spec.execute(fakeQueueRunner);
|
||||||
|
|
||||||
fakeQueueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
|
fakeQueueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
|
||||||
expect(startCallback).toHaveBeenCalled();
|
expect(startCallback).toHaveBeenCalled();
|
||||||
@@ -82,11 +80,10 @@ describe('Spec', function() {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
onStart: startCallback,
|
onStart: startCallback
|
||||||
queueRunnerFactory: fakeQueueRunner
|
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.execute();
|
spec.execute(fakeQueueRunner);
|
||||||
|
|
||||||
fakeQueueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
|
fakeQueueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
|
||||||
expect(startCallback).toHaveBeenCalled();
|
expect(startCallback).toHaveBeenCalled();
|
||||||
@@ -106,11 +103,10 @@ describe('Spec', function() {
|
|||||||
queueableFn: queueableFn,
|
queueableFn: queueableFn,
|
||||||
beforeAndAfterFns: function() {
|
beforeAndAfterFns: function() {
|
||||||
return { befores: [before], afters: [after] };
|
return { befores: [before], afters: [after] };
|
||||||
},
|
}
|
||||||
queueRunnerFactory: fakeQueueRunner
|
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.execute();
|
spec.execute(fakeQueueRunner);
|
||||||
|
|
||||||
const options = fakeQueueRunner.calls.mostRecent().args[0];
|
const options = fakeQueueRunner.calls.mostRecent().args[0];
|
||||||
expect(options.queueableFns).toEqual([
|
expect(options.queueableFns).toEqual([
|
||||||
@@ -131,11 +127,10 @@ describe('Spec', function() {
|
|||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
beforeAndAfterFns: function() {
|
beforeAndAfterFns: function() {
|
||||||
return { befores: [], afters: [] };
|
return { befores: [], afters: [] };
|
||||||
},
|
}
|
||||||
queueRunnerFactory: fakeQueueRunner
|
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.execute();
|
spec.execute(fakeQueueRunner);
|
||||||
|
|
||||||
expect(fakeQueueRunner).toHaveBeenCalledWith(
|
expect(fakeQueueRunner).toHaveBeenCalledWith(
|
||||||
jasmine.objectContaining({
|
jasmine.objectContaining({
|
||||||
@@ -145,14 +140,12 @@ describe('Spec', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('is marked pending if created without a function body', function() {
|
it('is marked pending if created without a function body', function() {
|
||||||
const fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
const startCallback = jasmine.createSpy('startCallback'),
|
||||||
startCallback = jasmine.createSpy('startCallback'),
|
|
||||||
resultCallback = jasmine.createSpy('resultCallback'),
|
resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new jasmineUnderTest.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
onStart: startCallback,
|
onStart: startCallback,
|
||||||
queueableFn: { fn: null },
|
queueableFn: { fn: null },
|
||||||
resultCallback: resultCallback,
|
resultCallback: resultCallback
|
||||||
queueRunnerFactory: fakeQueueRunner
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(spec.status()).toBe('pending');
|
expect(spec.status()).toBe('pending');
|
||||||
@@ -166,11 +159,10 @@ describe('Spec', function() {
|
|||||||
spec = new jasmineUnderTest.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
onStart: startCallback,
|
onStart: startCallback,
|
||||||
queueableFn: { fn: specBody },
|
queueableFn: { fn: specBody },
|
||||||
resultCallback: resultCallback,
|
resultCallback: resultCallback
|
||||||
queueRunnerFactory: fakeQueueRunner
|
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.execute('cally-back', true);
|
spec.execute(fakeQueueRunner, 'cally-back', true);
|
||||||
|
|
||||||
expect(fakeQueueRunner).toHaveBeenCalledWith(
|
expect(fakeQueueRunner).toHaveBeenCalledWith(
|
||||||
jasmine.objectContaining({
|
jasmine.objectContaining({
|
||||||
@@ -206,7 +198,6 @@ describe('Spec', function() {
|
|||||||
getSpecName: function() {
|
getSpecName: function() {
|
||||||
return 'a suite with a spec';
|
return 'a suite with a spec';
|
||||||
},
|
},
|
||||||
queueRunnerFactory: fakeQueueRunner,
|
|
||||||
queueableFn: { fn: null }
|
queueableFn: { fn: null }
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -214,7 +205,7 @@ describe('Spec', function() {
|
|||||||
|
|
||||||
expect(spec.status()).toBe('pending');
|
expect(spec.status()).toBe('pending');
|
||||||
|
|
||||||
spec.execute();
|
spec.execute(fakeQueueRunner);
|
||||||
|
|
||||||
expect(fakeQueueRunner).toHaveBeenCalled();
|
expect(fakeQueueRunner).toHaveBeenCalled();
|
||||||
|
|
||||||
@@ -247,13 +238,10 @@ describe('Spec', function() {
|
|||||||
catchExceptions: function() {
|
catchExceptions: function() {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
resultCallback: function() {},
|
resultCallback: function() {}
|
||||||
queueRunnerFactory: function(attrs) {
|
|
||||||
attrs.onComplete();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.execute(done);
|
spec.execute(attrs => attrs.onComplete(), done);
|
||||||
|
|
||||||
expect(done).toHaveBeenCalled();
|
expect(done).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@@ -265,14 +253,14 @@ describe('Spec', function() {
|
|||||||
catchExceptions: function() {
|
catchExceptions: function() {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
resultCallback: function() {},
|
resultCallback: function() {}
|
||||||
queueRunnerFactory: function(attrs) {
|
|
||||||
spec.result.status = 'failed';
|
|
||||||
attrs.onComplete();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.execute(done);
|
function queueRunnerFactory(attrs) {
|
||||||
|
spec.result.status = 'failed';
|
||||||
|
attrs.onComplete();
|
||||||
|
}
|
||||||
|
spec.execute(queueRunnerFactory, done);
|
||||||
|
|
||||||
expect(done).toHaveBeenCalledWith(
|
expect(done).toHaveBeenCalledWith(
|
||||||
jasmine.any(jasmineUnderTest.StopExecutionError)
|
jasmine.any(jasmineUnderTest.StopExecutionError)
|
||||||
@@ -293,16 +281,17 @@ describe('Spec', function() {
|
|||||||
resultCallback: function(result) {
|
resultCallback: function(result) {
|
||||||
duration = result.duration;
|
duration = result.duration;
|
||||||
},
|
},
|
||||||
queueRunnerFactory: function(config) {
|
|
||||||
config.queueableFns.forEach(function(qf) {
|
|
||||||
qf.fn();
|
|
||||||
});
|
|
||||||
config.onComplete();
|
|
||||||
},
|
|
||||||
timer: timer
|
timer: timer
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.execute(function() {});
|
function queueRunnerFactory(config) {
|
||||||
|
config.queueableFns.forEach(function(qf) {
|
||||||
|
qf.fn();
|
||||||
|
});
|
||||||
|
config.onComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
spec.execute(queueRunnerFactory, function() {});
|
||||||
expect(duration).toBe(77000);
|
expect(duration).toBe(77000);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -313,13 +302,10 @@ describe('Spec', function() {
|
|||||||
catchExceptions: function() {
|
catchExceptions: function() {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
resultCallback: function() {},
|
resultCallback: function() {}
|
||||||
queueRunnerFactory: function(attrs) {
|
|
||||||
attrs.onComplete();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
spec.setSpecProperty('a', 4);
|
spec.setSpecProperty('a', 4);
|
||||||
spec.execute(done);
|
spec.execute(attrs => attrs.onComplete(), done);
|
||||||
expect(spec.result.properties).toEqual({ a: 4 });
|
expect(spec.result.properties).toEqual({ a: 4 });
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -352,13 +338,12 @@ describe('Spec', function() {
|
|||||||
resultCallback = jasmine.createSpy('resultCallback'),
|
resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new jasmineUnderTest.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: jasmine.createSpy('spec body') },
|
queueableFn: { fn: jasmine.createSpy('spec body') },
|
||||||
queueRunnerFactory: fakeQueueRunner,
|
|
||||||
resultCallback: resultCallback
|
resultCallback: resultCallback
|
||||||
});
|
});
|
||||||
spec.addExpectationResult(true, { message: 'expectation1' });
|
spec.addExpectationResult(true, { message: 'expectation1' });
|
||||||
spec.addExpectationResult(false, { message: 'expectation2' });
|
spec.addExpectationResult(false, { message: 'expectation2' });
|
||||||
|
|
||||||
spec.execute();
|
spec.execute(fakeQueueRunner);
|
||||||
|
|
||||||
const fns = fakeQueueRunner.calls.mostRecent().args[0].queueableFns;
|
const fns = fakeQueueRunner.calls.mostRecent().args[0].queueableFns;
|
||||||
fns[fns.length - 1].fn();
|
fns[fns.length - 1].fn();
|
||||||
@@ -376,7 +361,6 @@ describe('Spec', function() {
|
|||||||
resultCallback = jasmine.createSpy('resultCallback'),
|
resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new jasmineUnderTest.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
queueRunnerFactory: fakeQueueRunner,
|
|
||||||
resultCallback: resultCallback,
|
resultCallback: resultCallback,
|
||||||
throwOnExpectationFailure: true
|
throwOnExpectationFailure: true
|
||||||
});
|
});
|
||||||
@@ -386,7 +370,7 @@ describe('Spec', function() {
|
|||||||
spec.addExpectationResult(false, { message: 'failed' });
|
spec.addExpectationResult(false, { message: 'failed' });
|
||||||
}).toThrowError(jasmineUnderTest.errors.ExpectationFailed);
|
}).toThrowError(jasmineUnderTest.errors.ExpectationFailed);
|
||||||
|
|
||||||
spec.execute();
|
spec.execute(fakeQueueRunner);
|
||||||
|
|
||||||
const fns = fakeQueueRunner.calls.mostRecent().args[0].queueableFns;
|
const fns = fakeQueueRunner.calls.mostRecent().args[0].queueableFns;
|
||||||
fns[fns.length - 1].fn();
|
fns[fns.length - 1].fn();
|
||||||
@@ -489,9 +473,6 @@ describe('Spec', function() {
|
|||||||
const resultCallback = jasmine.createSpy('resultCallback'),
|
const resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new jasmineUnderTest.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
queueRunnerFactory: function(attrs) {
|
|
||||||
attrs.onComplete();
|
|
||||||
},
|
|
||||||
resultCallback: resultCallback,
|
resultCallback: resultCallback,
|
||||||
throwOnExpectationFailure: true
|
throwOnExpectationFailure: true
|
||||||
});
|
});
|
||||||
@@ -523,11 +504,10 @@ describe('Spec', function() {
|
|||||||
spec = new jasmineUnderTest.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
description: 'my test',
|
description: 'my test',
|
||||||
id: 'some-id',
|
id: 'some-id',
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} }
|
||||||
queueRunnerFactory: fakeQueueRunner
|
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.execute();
|
spec.execute(fakeQueueRunner);
|
||||||
|
|
||||||
expect(spec.status()).toEqual('pending');
|
expect(spec.status()).toEqual('pending');
|
||||||
expect(spec.result.pendingReason).toEqual('');
|
expect(spec.result.pendingReason).toEqual('');
|
||||||
@@ -545,11 +525,10 @@ describe('Spec', function() {
|
|||||||
spec = new jasmineUnderTest.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
description: 'my test',
|
description: 'my test',
|
||||||
id: 'some-id',
|
id: 'some-id',
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} }
|
||||||
queueRunnerFactory: fakeQueueRunner
|
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.execute();
|
spec.execute(fakeQueueRunner);
|
||||||
|
|
||||||
expect(spec.status()).toEqual('pending');
|
expect(spec.status()).toEqual('pending');
|
||||||
expect(spec.result.pendingReason).toEqual('custom message');
|
expect(spec.result.pendingReason).toEqual('custom message');
|
||||||
@@ -561,12 +540,11 @@ describe('Spec', function() {
|
|||||||
resultCallback = jasmine.createSpy('resultCallback'),
|
resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new jasmineUnderTest.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
queueRunnerFactory: fakeQueueRunner,
|
|
||||||
resultCallback: resultCallback
|
resultCallback: resultCallback
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.handleException('foo');
|
spec.handleException('foo');
|
||||||
spec.execute();
|
spec.execute(fakeQueueRunner);
|
||||||
|
|
||||||
const args = fakeQueueRunner.calls.mostRecent().args[0];
|
const args = fakeQueueRunner.calls.mostRecent().args[0];
|
||||||
args.queueableFns[args.queueableFns.length - 1].fn();
|
args.queueableFns[args.queueableFns.length - 1].fn();
|
||||||
@@ -587,12 +565,11 @@ describe('Spec', function() {
|
|||||||
resultCallback = jasmine.createSpy('resultCallback'),
|
resultCallback = jasmine.createSpy('resultCallback'),
|
||||||
spec = new jasmineUnderTest.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
queueRunnerFactory: fakeQueueRunner,
|
|
||||||
resultCallback: resultCallback
|
resultCallback: resultCallback
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.handleException(new jasmineUnderTest.errors.ExpectationFailed());
|
spec.handleException(new jasmineUnderTest.errors.ExpectationFailed());
|
||||||
spec.execute();
|
spec.execute(fakeQueueRunner);
|
||||||
|
|
||||||
const args = fakeQueueRunner.calls.mostRecent().args[0];
|
const args = fakeQueueRunner.calls.mostRecent().args[0];
|
||||||
args.queueableFns[args.queueableFns.length - 1].fn();
|
args.queueableFns[args.queueableFns.length - 1].fn();
|
||||||
@@ -605,13 +582,12 @@ describe('Spec', function() {
|
|||||||
spec = new jasmineUnderTest.Spec({
|
spec = new jasmineUnderTest.Spec({
|
||||||
onLateError: onLateError,
|
onLateError: onLateError,
|
||||||
queueableFn: { fn: function() {} },
|
queueableFn: { fn: function() {} },
|
||||||
queueRunnerFactory: queueRunnerFactory,
|
|
||||||
getSpecName: function() {
|
getSpecName: function() {
|
||||||
return 'a spec';
|
return 'a spec';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.execute();
|
spec.execute(queueRunnerFactory);
|
||||||
|
|
||||||
expect(queueRunnerFactory).toHaveBeenCalled();
|
expect(queueRunnerFactory).toHaveBeenCalled();
|
||||||
queueRunnerFactory.calls.argsFor(0)[0].onMultipleDone();
|
queueRunnerFactory.calls.argsFor(0)[0].onMultipleDone();
|
||||||
@@ -631,13 +607,12 @@ describe('Spec', function() {
|
|||||||
queueableFn: {
|
queueableFn: {
|
||||||
fn: function() {}
|
fn: function() {}
|
||||||
},
|
},
|
||||||
queueRunnerFactory: function() {},
|
|
||||||
timer: timer
|
timer: timer
|
||||||
}),
|
}),
|
||||||
t1 = 123,
|
t1 = 123,
|
||||||
t2 = 456;
|
t2 = 456;
|
||||||
|
|
||||||
spec.execute();
|
spec.execute(() => {});
|
||||||
expect(spec.result.debugLogs).toBeNull();
|
expect(spec.result.debugLogs).toBeNull();
|
||||||
timer.elapsed.and.returnValue(t1);
|
timer.elapsed.and.returnValue(t1);
|
||||||
spec.debugLog('msg 1');
|
spec.debugLog('msg 1');
|
||||||
@@ -659,17 +634,18 @@ describe('Spec', function() {
|
|||||||
queueableFn: {
|
queueableFn: {
|
||||||
fn: function() {}
|
fn: function() {}
|
||||||
},
|
},
|
||||||
resultCallback: resultCallback,
|
resultCallback: resultCallback
|
||||||
queueRunnerFactory: function(config) {
|
|
||||||
spec.debugLog('msg');
|
|
||||||
for (const fn of config.queueableFns) {
|
|
||||||
fn.fn();
|
|
||||||
}
|
|
||||||
config.onComplete(false);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.execute(function() {});
|
function queueRunnerFactory(config) {
|
||||||
|
spec.debugLog('msg');
|
||||||
|
for (const fn of config.queueableFns) {
|
||||||
|
fn.fn();
|
||||||
|
}
|
||||||
|
config.onComplete(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
spec.execute(queueRunnerFactory, function() {});
|
||||||
expect(resultCallback).toHaveBeenCalledWith(
|
expect(resultCallback).toHaveBeenCalledWith(
|
||||||
jasmine.objectContaining({ debugLogs: null }),
|
jasmine.objectContaining({ debugLogs: null }),
|
||||||
undefined
|
undefined
|
||||||
@@ -682,17 +658,18 @@ describe('Spec', function() {
|
|||||||
queueableFn: {
|
queueableFn: {
|
||||||
fn: function() {}
|
fn: function() {}
|
||||||
},
|
},
|
||||||
resultCallback: resultCallback,
|
resultCallback: resultCallback
|
||||||
queueRunnerFactory: function(config) {
|
|
||||||
spec.debugLog('msg');
|
|
||||||
for (const fn of config.queueableFns) {
|
|
||||||
fn.fn();
|
|
||||||
}
|
|
||||||
config.onComplete(false);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
spec.execute(function() {});
|
function queueRunnerFactory(config) {
|
||||||
|
spec.debugLog('msg');
|
||||||
|
for (const fn of config.queueableFns) {
|
||||||
|
fn.fn();
|
||||||
|
}
|
||||||
|
config.onComplete(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
spec.execute(queueRunnerFactory, function() {});
|
||||||
expect(resultCallback).toHaveBeenCalled();
|
expect(resultCallback).toHaveBeenCalled();
|
||||||
expect(spec.result.debugLogs).toBeNull();
|
expect(spec.result.debugLogs).toBeNull();
|
||||||
});
|
});
|
||||||
@@ -707,21 +684,22 @@ describe('Spec', function() {
|
|||||||
fn: function() {}
|
fn: function() {}
|
||||||
},
|
},
|
||||||
resultCallback: resultCallback,
|
resultCallback: resultCallback,
|
||||||
queueRunnerFactory: function(config) {
|
|
||||||
spec.debugLog('msg');
|
|
||||||
spec.handleException(new Error('nope'));
|
|
||||||
for (const fn of config.queueableFns) {
|
|
||||||
fn.fn();
|
|
||||||
}
|
|
||||||
config.onComplete(true);
|
|
||||||
},
|
|
||||||
timer: timer
|
timer: timer
|
||||||
}),
|
}),
|
||||||
timestamp = 12345;
|
timestamp = 12345;
|
||||||
|
|
||||||
timer.elapsed.and.returnValue(timestamp);
|
timer.elapsed.and.returnValue(timestamp);
|
||||||
|
|
||||||
spec.execute(function() {});
|
function queueRunnerFactory(config) {
|
||||||
|
spec.debugLog('msg');
|
||||||
|
spec.handleException(new Error('nope'));
|
||||||
|
for (const fn of config.queueableFns) {
|
||||||
|
fn.fn();
|
||||||
|
}
|
||||||
|
config.onComplete(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
spec.execute(queueRunnerFactory, function() {});
|
||||||
expect(resultCallback).toHaveBeenCalledWith(
|
expect(resultCallback).toHaveBeenCalledWith(
|
||||||
jasmine.objectContaining({
|
jasmine.objectContaining({
|
||||||
debugLogs: [{ message: 'msg', timestamp: timestamp }]
|
debugLogs: [{ message: 'msg', timestamp: timestamp }]
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ describe('TreeProcessor', function() {
|
|||||||
|
|
||||||
queueRunner.calls.mostRecent().args[0].queueableFns[0].fn('foo');
|
queueRunner.calls.mostRecent().args[0].queueableFns[0].fn('foo');
|
||||||
|
|
||||||
expect(leaf.execute).toHaveBeenCalledWith('foo', false, false);
|
expect(leaf.execute).toHaveBeenCalledWith(queueRunner, 'foo', false, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('runs a node with no children', function() {
|
it('runs a node with no children', function() {
|
||||||
@@ -372,10 +372,20 @@ describe('TreeProcessor', function() {
|
|||||||
expect(queueableFns.length).toBe(3);
|
expect(queueableFns.length).toBe(3);
|
||||||
|
|
||||||
queueableFns[1].fn('foo');
|
queueableFns[1].fn('foo');
|
||||||
expect(leaf1.execute).toHaveBeenCalledWith('foo', false, false);
|
expect(leaf1.execute).toHaveBeenCalledWith(
|
||||||
|
queueRunner,
|
||||||
|
'foo',
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
queueableFns[2].fn('bar');
|
queueableFns[2].fn('bar');
|
||||||
expect(leaf2.execute).toHaveBeenCalledWith('bar', false, false);
|
expect(leaf2.execute).toHaveBeenCalledWith(
|
||||||
|
queueRunner,
|
||||||
|
'bar',
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('cascades errors up the tree', function() {
|
it('cascades errors up the tree', function() {
|
||||||
@@ -401,7 +411,7 @@ describe('TreeProcessor', function() {
|
|||||||
expect(queueableFns.length).toBe(2);
|
expect(queueableFns.length).toBe(2);
|
||||||
|
|
||||||
queueableFns[1].fn('foo');
|
queueableFns[1].fn('foo');
|
||||||
expect(leaf.execute).toHaveBeenCalledWith('foo', false, false);
|
expect(leaf.execute).toHaveBeenCalledWith(queueRunner, 'foo', false, false);
|
||||||
|
|
||||||
queueRunner.calls.mostRecent().args[0].onComplete('things');
|
queueRunner.calls.mostRecent().args[0].onComplete('things');
|
||||||
expect(nodeComplete).toHaveBeenCalled();
|
expect(nodeComplete).toHaveBeenCalled();
|
||||||
@@ -437,7 +447,7 @@ describe('TreeProcessor', function() {
|
|||||||
expect(nodeStart).toHaveBeenCalledWith(node, 'bar');
|
expect(nodeStart).toHaveBeenCalledWith(node, 'bar');
|
||||||
|
|
||||||
queueableFns[1].fn('foo');
|
queueableFns[1].fn('foo');
|
||||||
expect(leaf1.execute).toHaveBeenCalledWith('foo', true, false);
|
expect(leaf1.execute).toHaveBeenCalledWith(queueRunner, 'foo', true, false);
|
||||||
|
|
||||||
node.getResult.and.returnValue({ im: 'disabled' });
|
node.getResult.and.returnValue({ im: 'disabled' });
|
||||||
|
|
||||||
@@ -475,7 +485,7 @@ describe('TreeProcessor', function() {
|
|||||||
expect(queueableFns.length).toBe(2);
|
expect(queueableFns.length).toBe(2);
|
||||||
|
|
||||||
queueableFns[1].fn('foo');
|
queueableFns[1].fn('foo');
|
||||||
expect(leaf.execute).toHaveBeenCalledWith('foo', true, true);
|
expect(leaf.execute).toHaveBeenCalledWith(queueRunner, 'foo', true, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('runs beforeAlls for a node with children', function() {
|
it('runs beforeAlls for a node with children', function() {
|
||||||
@@ -637,11 +647,21 @@ describe('TreeProcessor', function() {
|
|||||||
queueableFns[0].fn();
|
queueableFns[0].fn();
|
||||||
|
|
||||||
expect(nonSpecified.execute).not.toHaveBeenCalled();
|
expect(nonSpecified.execute).not.toHaveBeenCalled();
|
||||||
expect(specified.execute).toHaveBeenCalledWith(undefined, false, false);
|
expect(specified.execute).toHaveBeenCalledWith(
|
||||||
|
queueRunner,
|
||||||
|
undefined,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
queueableFns[1].fn();
|
queueableFns[1].fn();
|
||||||
|
|
||||||
expect(nonSpecified.execute).toHaveBeenCalledWith(undefined, true, false);
|
expect(nonSpecified.execute).toHaveBeenCalledWith(
|
||||||
|
queueRunner,
|
||||||
|
undefined,
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('runs nodes and leaves with a specified order', function() {
|
it('runs nodes and leaves with a specified order', function() {
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
deprecator.addDeprecationWarning(runable, deprecation, options);
|
deprecator.addDeprecationWarning(runable, deprecation, options);
|
||||||
};
|
};
|
||||||
|
|
||||||
function queueRunnerFactory(options, args) {
|
function queueRunnerFactory(options) {
|
||||||
if (options.isLeaf) {
|
if (options.isLeaf) {
|
||||||
// A spec
|
// A spec
|
||||||
options.SkipPolicy = j$.CompleteOnFirstErrorSkipPolicy;
|
options.SkipPolicy = j$.CompleteOnFirstErrorSkipPolicy;
|
||||||
@@ -404,7 +404,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
};
|
};
|
||||||
options.deprecated = self.deprecated;
|
options.deprecated = self.deprecated;
|
||||||
|
|
||||||
new j$.QueueRunner(options).execute(args);
|
new j$.QueueRunner(options).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
const suiteBuilder = new j$.SuiteBuilder({
|
const suiteBuilder = new j$.SuiteBuilder({
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
this.onLateError = attrs.onLateError || function() {};
|
this.onLateError = attrs.onLateError || function() {};
|
||||||
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
|
|
||||||
this.catchingExceptions =
|
this.catchingExceptions =
|
||||||
attrs.catchingExceptions ||
|
attrs.catchingExceptions ||
|
||||||
function() {
|
function() {
|
||||||
@@ -99,7 +98,12 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
return this.asyncExpectationFactory(actual, this);
|
return this.asyncExpectationFactory(actual, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
Spec.prototype.execute = function(onComplete, excluded, failSpecWithNoExp) {
|
Spec.prototype.execute = function(
|
||||||
|
queueRunnerFactory,
|
||||||
|
onComplete,
|
||||||
|
excluded,
|
||||||
|
failSpecWithNoExp
|
||||||
|
) {
|
||||||
const onStart = {
|
const onStart = {
|
||||||
fn: done => {
|
fn: done => {
|
||||||
this.timer.start();
|
this.timer.start();
|
||||||
@@ -161,7 +165,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
runnerConfig.queueableFns.unshift(onStart);
|
runnerConfig.queueableFns.unshift(onStart);
|
||||||
runnerConfig.queueableFns.push(complete);
|
runnerConfig.queueableFns.push(complete);
|
||||||
|
|
||||||
this.queueRunnerFactory(runnerConfig);
|
queueRunnerFactory(runnerConfig);
|
||||||
};
|
};
|
||||||
|
|
||||||
Spec.prototype.reset = function() {
|
Spec.prototype.reset = function() {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
|||||||
this.onLateError_ = options.onLateError;
|
this.onLateError_ = options.onLateError;
|
||||||
this.specResultCallback_ = options.specResultCallback;
|
this.specResultCallback_ = options.specResultCallback;
|
||||||
this.specStarted_ = options.specStarted;
|
this.specStarted_ = options.specStarted;
|
||||||
this.queueRunnerFactory_ = options.queueRunnerFactory;
|
|
||||||
|
|
||||||
this.nextSuiteId_ = 0;
|
this.nextSuiteId_ = 0;
|
||||||
this.nextSpecId_ = 0;
|
this.nextSpecId_ = 0;
|
||||||
@@ -212,7 +211,6 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
|||||||
},
|
},
|
||||||
onStart: (spec, next) => this.specStarted_(spec, suite, next),
|
onStart: (spec, next) => this.specStarted_(spec, suite, next),
|
||||||
description: description,
|
description: description,
|
||||||
queueRunnerFactory: this.queueRunnerFactory_,
|
|
||||||
userContext: function() {
|
userContext: function() {
|
||||||
return suite.clonedSharedUserContext();
|
return suite.clonedSharedUserContext();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|||||||
return {
|
return {
|
||||||
fn: function(done) {
|
fn: function(done) {
|
||||||
node.execute(
|
node.execute(
|
||||||
|
queueRunnerFactory,
|
||||||
done,
|
done,
|
||||||
stats[node.id].excluded,
|
stats[node.id].excluded,
|
||||||
failSpecWithNoExpectations
|
failSpecWithNoExpectations
|
||||||
|
|||||||
Reference in New Issue
Block a user