diff options
| author | Misko Hevery | 2013-07-31 16:54:21 -0700 |
|---|---|---|
| committer | Misko Hevery | 2013-07-31 17:10:10 -0700 |
| commit | 90532f5e3c2016c99833a4dd779a5c4718c84f4d (patch) | |
| tree | 5c0763df89bc1c5c10e10895b9776b597d23c533 /test | |
| parent | 2bc04d23fbc302e6dd52ab80a621aa264548d9e3 (diff) | |
| download | angular.js-90532f5e3c2016c99833a4dd779a5c4718c84f4d.tar.bz2 | |
fix(location): fix parameter handling on search()
Diffstat (limited to 'test')
| -rw-r--r-- | test/ng/locationSpec.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index b6efe783..0158bf61 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -78,6 +78,35 @@ describe('$location', function() { }); + it('search() should handle multiple value', function() { + url.search('a&b'); + expect(url.search()).toEqual({a: true, b: true}); + + url.search('a', null); + + expect(url.search()).toEqual({b: true}); + + url.search('b', undefined); + expect(url.search()).toEqual({}); + }); + + + it('search() should handle single value', function() { + url.search('ignore'); + expect(url.search()).toEqual({ignore: true}); + }); + + + it('search() should throw error an incorrect argument', function() { + expect(function() { + url.search(null); + }).toThrow('[$location:wpt] First parameter of function must be string or an object.'); + expect(function() { + url.search(undefined); + }).toThrow('[$location:wpt] First parameter of function must be string or an object.'); + }); + + it('hash() should change hash fragment', function() { url.hash('new-hash'); expect(url.hash()).toBe('new-hash'); |
