fix($q): fix forwarding resolution when callbacks aren't functions

Uses the changes from @jamestalmage's fix in #3535. (thanks!)

Closes #3535
This commit is contained in:
Brian Ford
2013-08-21 16:40:20 -07:00
parent 8ee9a3e902
commit 7d188d630c
2 changed files with 41 additions and 9 deletions

View File

@@ -730,6 +730,38 @@ describe('q', function() {
mockNextTick.flush();
expect(log).toEqual(['error(oops!)->reject(oops!)']);
});
it('should forward success resolution when success callbacks are not functions', function() {
deferred.resolve('yay!');
promise.then(1).
then(null).
then({}).
then('gah!').
then([]).
then(success());
expect(logStr()).toBe('');
mockNextTick.flush();
expect(log).toEqual(['success(yay!)->yay!']);
});
it('should forward error resolution when error callbacks are not functions', function() {
deferred.reject('oops!');
promise.then(null, 1).
then(null, null).
then(null, {}).
then(null, 'gah!').
then(null, []).
then(null, error());
expect(logStr()).toBe('');
mockNextTick.flush();
expect(log).toEqual(['error(oops!)->reject(oops!)']);
});
});