From a207665dad69248139b150cd3fe8ba13059bffb4 Mon Sep 17 00:00:00 2001 From: bolasblack Date: Tue, 6 Aug 2013 17:48:32 +0800 Subject: 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 --- test/ng/qSpec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') 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)'); + }); + }); }); }); -- cgit v1.2.3