diff options
| author | Igor Minar | 2010-09-27 16:00:05 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-09-29 09:52:03 -0700 |
| commit | eb8d46d380a2005dbec3973d40e1dbc27991fdb7 (patch) | |
| tree | 59a3e8d7bba0c4704b759efb38d1c72e5a85dc75 /test/AngularSpec.js | |
| parent | 984acdc6270df1dee5796ed44efebfb9ff6706c7 (diff) | |
| download | angular.js-eb8d46d380a2005dbec3973d40e1dbc27991fdb7.tar.bz2 | |
Differentiate between flags and empty keys in $location.hashSearch
* #foo?key=var&flag&emptyKey= should parse into
{key:'val', flag: true, emptyKey: ''}
* added docs and spec for parseKeyValue function
Diffstat (limited to 'test/AngularSpec.js')
| -rw-r--r-- | test/AngularSpec.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/AngularSpec.js b/test/AngularSpec.js index b4e90175..725e8ea0 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -79,5 +79,17 @@ describe('equals', function(){ expect(equals({name:'misko'}, {name:'misko', $id:2})).toEqual(true); expect(equals({name:'misko', $id:1}, {name:'misko'})).toEqual(true); }); - }); + +describe('parseKeyValue', function() { + it('should parse a string into key-value pairs', function() { + expect(parseKeyValue('')).toEqual({}); + expect(parseKeyValue('simple=pair')).toEqual({simple: 'pair'}); + expect(parseKeyValue('first=1&second=2')).toEqual({first: '1', second: '2'}); + expect(parseKeyValue('escaped%20key=escaped%20value')). + toEqual({'escaped key': 'escaped value'}); + expect(parseKeyValue('emptyKey=')).toEqual({emptyKey: ''}); + expect(parseKeyValue('flag1&key=value&flag2')). + toEqual({flag1: true, key: 'value', flag2: true}); + }); +}) |
