Created
September 22, 2014 10:22
-
-
Save amyboyd/68a86fe3f65a77fcfc7f to your computer and use it in GitHub Desktop.
Karma tests for http://stackoverflow.com/a/13419367/224004
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/a/13419367/224004 | |
describe('parseQuery', function() { | |
it('parses a simple query string that starts with a ?', function() { | |
expect(parseQuery('?a=z')).toEqual({'a': 'z'}); | |
}); | |
it('parses a simple query string that doesn\'t start with a ?', function() { | |
expect(parseQuery('a=z')).toEqual({'a': 'z'}); | |
}); | |
it('decodes entities', function() { | |
expect(parseQuery('%5Ba%5D%20(%20v%20)=%5Ba%5D%20(%20v%20)')).toEqual({'[a] ( v )': '[a] ( v )'}); | |
}); | |
it('parses a query string with multiple values', function() { | |
expect(parseQuery('%5B=2&2=3')).toEqual({'[': '2', '2': '3'}); | |
}); | |
it('uses the last key value if there are duplicate keys', function() { | |
expect(parseQuery('?a=1&a=2&a=3&b=2&b=1')).toEqual({'a': '3', 'b': '1'}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment