aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/locationSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/ng/locationSpec.js')
-rw-r--r--test/ng/locationSpec.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js
index df8043a3..df826525 100644
--- a/test/ng/locationSpec.js
+++ b/test/ng/locationSpec.js
@@ -368,6 +368,29 @@ describe('$location', function() {
locationUrl.search('q', '1/2 3');
expect(locationUrl.search()).toEqual({'q': '1/2 3'});
});
+
+ it('should return an array for duplicate params', function() {
+ var locationUrl = new LocationHtml5Url('http://host.com');
+ locationUrl.$$parse('http://host.com')
+ locationUrl.search('q', ['1/2 3','4/5 6']);
+ expect(locationUrl.search()).toEqual({'q': ['1/2 3','4/5 6']});
+ });
+
+ it('should encode an array correctly from search and add to url', function() {
+ var locationUrl = new LocationHtml5Url('http://host.com');
+ locationUrl.$$parse('http://host.com')
+ locationUrl.search({'q': ['1/2 3','4/5 6']});
+ expect(locationUrl.absUrl()).toEqual('http://host.com?q=1%2F2%203&q=4%2F5%206');
+ });
+
+ it('should rewrite params when specifing a single param in search', function() {
+ var locationUrl = new LocationHtml5Url('http://host.com');
+ locationUrl.$$parse('http://host.com')
+ locationUrl.search({'q': '1/2 3'});
+ expect(locationUrl.absUrl()).toEqual('http://host.com?q=1%2F2%203');
+ locationUrl.search({'q': '4/5 6'});
+ expect(locationUrl.absUrl()).toEqual('http://host.com?q=4%2F5%206');
+ });
});
});