Fixed pending() for async/promise-returning specs

Fixes #1449.
Fixes #1450.
This commit is contained in:
Steve Gravrock
2017-11-29 08:56:12 -08:00
parent 13b9e669bd
commit f4caf27208
4 changed files with 50 additions and 7 deletions

View File

@@ -375,27 +375,31 @@ describe("QueueRunner", function() {
expect(onComplete).toHaveBeenCalled();
});
it("fails the function when the promise is rejected", function() {
it("handles a rejected promise like an unhandled exception", function() {
var promise = new StubPromise(),
queueableFn1 = { fn: function() {
setTimeout(function() { promise.rejectHandler('foo'); }, 100);
setTimeout(function() {
debugger;
promise.rejectHandler('foo')
}, 100);
return promise;
} },
queueableFn2 = { fn: jasmine.createSpy('fn2') },
failFn = jasmine.createSpy('fail'),
onExceptionCallback = jasmine.createSpy('on exception callback'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn1, queueableFn2],
fail: failFn
onException: onExceptionCallback
});
queueRunner.execute();
expect(failFn).not.toHaveBeenCalled();
expect(onExceptionCallback).not.toHaveBeenCalled();
expect(queueableFn2.fn).not.toHaveBeenCalled();
jasmine.clock().tick(100);
expect(failFn).toHaveBeenCalledWith('foo');
expect(onExceptionCallback).toHaveBeenCalledWith('foo');
expect(queueableFn2.fn).toHaveBeenCalled();
});
});