aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/rootScopeSpec.js
diff options
context:
space:
mode:
authorDaniel Luz2012-11-04 19:11:24 -0200
committerMisko Hevery2013-02-14 14:43:56 -0800
commit1d7a95df565192fc02a18b0b297b39dd615eaeb5 (patch)
tree9a307559c483251b40e500739ce96db85731712f /test/ng/rootScopeSpec.js
parent1ed638582d2f2c7f89384d9712f4cfac52cc5b70 (diff)
downloadangular.js-1d7a95df565192fc02a18b0b297b39dd615eaeb5.tar.bz2
feat(scope): only evaluate constant $watch expressions once
Diffstat (limited to 'test/ng/rootScopeSpec.js')
-rw-r--r--test/ng/rootScopeSpec.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/ng/rootScopeSpec.js b/test/ng/rootScopeSpec.js
index 49364888..33db814c 100644
--- a/test/ng/rootScopeSpec.js
+++ b/test/ng/rootScopeSpec.js
@@ -99,6 +99,14 @@ describe('Scope', function() {
expect(spy).wasCalled();
}));
+ it('should not keep constant expressions on watch queue', inject(function($rootScope) {
+ $rootScope.$watch('1 + 1', function() {});
+ expect($rootScope.$$watchers.length).toEqual(1);
+ $rootScope.$digest();
+
+ expect($rootScope.$$watchers.length).toEqual(0);
+ }));
+
it('should delegate exceptions', function() {
module(function($exceptionHandlerProvider) {
@@ -119,10 +127,14 @@ describe('Scope', function() {
var log = '';
$rootScope.$watch('a', function() { log += 'a'; });
$rootScope.$watch('b', function() { log += 'b'; });
+ // constant expressions have slightly different handling,
+ // let's ensure they are kept in the same list as others
+ $rootScope.$watch('1', function() { log += '1'; });
$rootScope.$watch('c', function() { log += 'c'; });
+ $rootScope.$watch('2', function() { log += '2'; });
$rootScope.a = $rootScope.b = $rootScope.c = 1;
$rootScope.$digest();
- expect(log).toEqual('abc');
+ expect(log).toEqual('ab1c2');
}));