aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorbolasblack2013-08-06 17:48:32 +0800
committerIgor Minar2013-08-09 09:02:58 -0700
commita207665dad69248139b150cd3fe8ba13059bffb4 (patch)
tree48be81627bcef0e8fe3f495c175c8b055c754cd0 /test
parentb3087421f20241f9bcb9b1f00ee9a30efc8b0899 (diff)
downloadangular.js-a207665dad69248139b150cd3fe8ba13059bffb4.tar.bz2
feat($q): add shorthand for defining promise error handlers
Now we can instead this promise.then(null, errorHandler) with this promise.catch(errorhandler) Closes #2048 Closes #3476
Diffstat (limited to 'test')
-rw-r--r--test/ng/qSpec.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ng/qSpec.js b/test/ng/qSpec.js
index 6d08cb15..4f2492fb 100644
--- a/test/ng/qSpec.js
+++ b/test/ng/qSpec.js
@@ -516,6 +516,10 @@ describe('q', function() {
expect(typeof promise.then).toBe('function');
});
+ it('should have a catch method', function() {
+ expect(typeof promise['catch']).toBe('function');
+ });
+
it('should have a always method', function() {
expect(typeof promise.always).toBe('function');
});
@@ -881,6 +885,14 @@ describe('q', function() {
});
});
+
+ describe('catch', function() {
+ it('should be a shorthand for defining promise error handlers', function() {
+ promise['catch'](error(1)).then(null, error(2))
+ syncReject(deferred, 'foo');
+ expect(logStr()).toBe('error1(foo)->reject(foo); error2(foo)->reject(foo)');
+ });
+ });
});
});