diff options
| author | Igor Minar | 2011-03-27 15:58:24 -0700 | 
|---|---|---|
| committer | Igor Minar | 2011-03-30 15:24:03 -0700 | 
| commit | 96a1df192a167e6e34988af687693506f4efd1d1 (patch) | |
| tree | df4603b0e1043500aaecc5c51a257371ad9f2732 /test/AngularSpec.js | |
| parent | 89c25fe7136e49faa88a4b2a1922c822a5470313 (diff) | |
| download | angular.js-96a1df192a167e6e34988af687693506f4efd1d1.tar.bz2 | |
extend size() to take ownPropsOnly param
- extend size() to take size(obj, ownPropsOnly)
- add specs for size()
- update docs to mention string support
- use size() in ng:repeat
including the hasOwnProp check for all object doesn't create
significant perf penalty:
http://jsperf.com/dedicated-code-branch-for-hasownprop
Diffstat (limited to 'test/AngularSpec.js')
| -rw-r--r-- | test/AngularSpec.js | 26 | 
1 files changed, 26 insertions, 0 deletions
| diff --git a/test/AngularSpec.js b/test/AngularSpec.js index cbae0606..0a290381 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -110,6 +110,32 @@ describe('angular', function(){      });    }); + +  describe('size', function() { +    it('should return the number of items in an array', function() { +      expect(size([])).toBe(0); +      expect(size(['a', 'b', 'c'])).toBe(3); +    }); + +    it('should return the number of properties of an object', function() { +      expect(size({})).toBe(0); +      expect(size({a:1, b:'a', c:noop})).toBe(3); +    }); + +    it('should return the number of own properties of an object', function() { +      var obj = inherit({protoProp: 'c', protoFn: noop}, {a:1, b:'a', c:noop}); + +      expect(size(obj)).toBe(5); +      expect(size(obj, true)).toBe(3); +    }); + +    it('should return the string length', function() { +      expect(size('')).toBe(0); +      expect(size('abc')).toBe(3); +    }); +  }); + +    describe('parseKeyValue', function() {      it('should parse a string into key-value pairs', function() {        expect(parseKeyValue('')).toEqual({}); | 
