aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/parseSpec.js
diff options
context:
space:
mode:
authorJussi Kosunen2013-08-15 15:14:54 +0300
committerVojta Jina2013-08-15 15:15:27 -0700
commit3a65822023119b71deab5e298c7ef2de204caa13 (patch)
treea10f4c3b80f786401b62cbd92e7941420c85f687 /test/ng/parseSpec.js
parent37123cd2858b4e318ed8109af745312df4848577 (diff)
downloadangular.js-3a65822023119b71deab5e298c7ef2de204caa13.tar.bz2
fix($parse): handle promises returned from parsed function calls
When a parsed function call returns a promise, the evaluated value is the resolved value of the promise rather than the promise object. Closes #3503
Diffstat (limited to 'test/ng/parseSpec.js')
-rw-r--r--test/ng/parseSpec.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ng/parseSpec.js b/test/ng/parseSpec.js
index f9a80fb6..7673066b 100644
--- a/test/ng/parseSpec.js
+++ b/test/ng/parseSpec.js
@@ -846,6 +846,18 @@ describe('parser', function() {
expect(scope.$eval('greeting')).toBe(undefined);
});
+ it('should evaluate a function call returning a promise and eventually get its return value', function() {
+ scope.greetingFn = function() { return promise; };
+ expect(scope.$eval('greetingFn()')).toBe(undefined);
+
+ scope.$digest();
+ expect(scope.$eval('greetingFn()')).toBe(undefined);
+
+ deferred.resolve('hello!');
+ expect(scope.$eval('greetingFn()')).toBe(undefined);
+ scope.$digest();
+ expect(scope.$eval('greetingFn()')).toBe('hello!');
+ });
describe('assignment into promises', function() {
// This behavior is analogous to assignments to non-promise values