aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMisko Hevery2013-07-31 16:54:21 -0700
committerMisko Hevery2013-07-31 16:55:06 -0700
commit705c9d95bc3157547ac6008d2f0a6a0c0e0ca60a (patch)
treef88e8de9e31fba05b232fe6bf841bd62cf886988 /test
parent61906d3517428b6d52d3284b8d26d1a46e01dad7 (diff)
downloadangular.js-705c9d95bc3157547ac6008d2f0a6a0c0e0ca60a.tar.bz2
fix(location): fix parameter handling on search()
Diffstat (limited to 'test')
-rw-r--r--test/ng/locationSpec.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js
index df826525..708b4a13 100644
--- a/test/ng/locationSpec.js
+++ b/test/ng/locationSpec.js
@@ -66,6 +66,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');