From 8d7e6948496ff26ef1da8854ba02fcb8eebfed61 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 21 Mar 2012 15:42:35 -0700 Subject: fix(forEach): should ignore prototypically inherited properties Closes #813 --- test/AngularSpec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test') diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 92949b66..cb0c5c6b 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -234,6 +234,25 @@ describe('angular', function() { }); }); + + describe('forEach', function() { + it('should iterate over *own* object properties', function() { + function MyObj() { + this.bar = 'barVal'; + this.baz = 'bazVal'; + }; + MyObj.prototype.foo = 'fooVal'; + + var obj = new MyObj(), + log = []; + + forEach(obj, function(value, key) { log.push(key + ':' + value)}); + + expect(log).toEqual(['bar:barVal', 'baz:bazVal']); + }); + }); + + describe('sortedKeys', function() { it('should collect keys from object', function() { expect(sortedKeys({c:0, b:0, a:0})).toEqual(['a', 'b', 'c']); -- cgit v1.2.3