diff options
| author | Igor Minar | 2010-11-22 10:23:45 -0800 |
|---|---|---|
| committer | Igor Minar | 2010-11-22 10:57:32 -0800 |
| commit | efec0c358d3cb840275037d5f86347130bb86573 (patch) | |
| tree | a727e5a244fc36c7f9bdd55e9b2bb0bcaba7c4cf /test/ApiSpecs.js | |
| parent | 1f59de35c94448e32ac72c0a9b8541ad4f8696ab (diff) | |
| download | angular.js-efec0c358d3cb840275037d5f86347130bb86573.tar.bz2 | |
Add angular.Array.limitTo and docs for angular.Array
Diffstat (limited to 'test/ApiSpecs.js')
| -rw-r--r-- | test/ApiSpecs.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/ApiSpecs.js b/test/ApiSpecs.js index 81fd9155..e2a68a61 100644 --- a/test/ApiSpecs.js +++ b/test/ApiSpecs.js @@ -115,6 +115,36 @@ describe('api', function(){ }); + describe('limit', function() { + var items; + + beforeEach(function() { + items = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']; + }); + + + it('should return the first X items when X is positive', function() { + expect(angular.Array.limitTo(items, 3)).toEqual(['a', 'b', 'c']); + expect(angular.Array.limitTo(items, '3')).toEqual(['a', 'b', 'c']); + }); + + + it('should return the last X items when X is negative', function() { + expect(angular.Array.limitTo(items, -3)).toEqual(['f', 'g', 'h']); + expect(angular.Array.limitTo(items, '-3')).toEqual(['f', 'g', 'h']); + }); + + + it('should return an empty array when X cannot be parsed', function() { + expect(angular.Array.limitTo(items, 'bogus')).toEqual([]); + expect(angular.Array.limitTo(items, 'null')).toEqual([]); + expect(angular.Array.limitTo(items, 'undefined')).toEqual([]); + expect(angular.Array.limitTo(items, null)).toEqual([]); + expect(angular.Array.limitTo(items, undefined)).toEqual([]); + }) + }); + + it('Add', function(){ var add = angular.Array.add; assertJsonEquals([{}, "a"], add(add([]),"a")); |
