diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/ng/rootScopeSpec.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ng/rootScopeSpec.js b/test/ng/rootScopeSpec.js index cd8d4109..cac7c160 100644 --- a/test/ng/rootScopeSpec.js +++ b/test/ng/rootScopeSpec.js @@ -463,6 +463,23 @@ describe('Scope', function() { $rootScope.$digest(); expect(log).toEqual([ '[{},[]]' ]); }); + + it('should watch array-like objects like arrays', function () { + var arrayLikelog = []; + $rootScope.$watchCollection('arrayLikeObject', function logger(obj) { + forEach(obj, function (element){ + arrayLikelog.push(element.name); + }) + }); + document.body.innerHTML = "<p>" + + "<a name='x'>a</a>" + + "<a name='y'>b</a>" + + "</p>"; + + $rootScope.arrayLikeObject = document.getElementsByTagName('a') + $rootScope.$digest(); + expect(arrayLikelog).toEqual(['x', 'y']); + }); }); |
