Add explicit fail and move on for async functions
- `done` now has a `fail` property which will call the global `fail` then continue to the next function in the queue [finish #73744618] Fix #567 Fix #568
This commit is contained in:
@@ -93,6 +93,28 @@ describe("QueueRunner", function() {
|
||||
expect(onComplete).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("explicitly fails an async function with a provided fail function and moves to the next function", function() {
|
||||
var queueableFn1 = { fn: function(done) {
|
||||
setTimeout(function() { done.fail('foo'); }, 100);
|
||||
} },
|
||||
queueableFn2 = { fn: jasmine.createSpy('fn2') },
|
||||
failFn = jasmine.createSpy('fail'),
|
||||
queueRunner = new j$.QueueRunner({
|
||||
queueableFns: [queueableFn1, queueableFn2],
|
||||
fail: failFn
|
||||
});
|
||||
|
||||
queueRunner.execute();
|
||||
|
||||
expect(failFn).not.toHaveBeenCalled();
|
||||
expect(queueableFn2.fn).not.toHaveBeenCalled();
|
||||
|
||||
jasmine.clock().tick(100);
|
||||
|
||||
expect(failFn).toHaveBeenCalledWith('foo');
|
||||
expect(queueableFn2.fn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("sets a timeout if requested for asynchronous functions so they don't go on forever", function() {
|
||||
var timeout = 3,
|
||||
beforeFn = { fn: function(done) { }, type: 'before', timeout: function() { return timeout; } },
|
||||
|
||||
@@ -972,6 +972,12 @@ describe("Env integration", function() {
|
||||
message: 'Failed: messy message'
|
||||
})]
|
||||
}));
|
||||
expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||
description: 'fails via the done callback',
|
||||
failedExpectations: [jasmine.objectContaining({
|
||||
message: 'Failed: done failed'
|
||||
})]
|
||||
}));
|
||||
expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||
description: 'has a message from an Error',
|
||||
failedExpectations: [jasmine.objectContaining({
|
||||
@@ -997,6 +1003,12 @@ describe("Env integration", function() {
|
||||
}, 1);
|
||||
});
|
||||
|
||||
env.it('fails via the done callback', function(innerDone) {
|
||||
setTimeout(function() {
|
||||
innerDone.fail('done failed');
|
||||
}, 1);
|
||||
});
|
||||
|
||||
env.it('has a message from an Error', function(innerDone) {
|
||||
setTimeout(function() {
|
||||
env.fail(new Error('error message'));
|
||||
|
||||
Reference in New Issue
Block a user