mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 19:40:56 +08:00
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:
@@ -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!)']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user