Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 37d9230

Browse files
dmartresjbedard
authored andcommitted
test($browser): add tests for apostrophes in urls
1 parent 5dad293 commit 37d9230

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

test/ng/browserSpecs.js

+68
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,76 @@ describe('browser', function() {
10011001
});
10021002
});
10031003

1004+
1005+
it('should work with apostrophes in url with no history support, no html5Mode', function() {
1006+
setup({
1007+
history: false,
1008+
html5Mode: false
1009+
});
1010+
1011+
inject(function($rootScope, $location) {
1012+
/* all aphostrofes in url should be replaced */
1013+
fakeWindow.location.href = 'http://server/#!/param1=data%27s1&param2=data%27s2';
1014+
$rootScope.$digest();
1015+
expect($location.path()).toBe('/param1=data\'s1&param2=data\'s2');
1016+
1017+
/* validate that location.href could be updated */
1018+
fakeWindow.location.href = 'http://server/#!/data1=anotherValue%27s1&data2=anotherValue%27s2';
1019+
$rootScope.$digest();
1020+
expect($location.path()).toBe('/data1=anotherValue\'s1&data2=anotherValue\'s2');
1021+
});
1022+
});
1023+
1024+
it('should work with apostrophes in url with html5Mode and no history support', function() {
1025+
setup({
1026+
history: false,
1027+
html5Mode: true
1028+
});
1029+
1030+
inject(function($rootScope, $location) {
1031+
1032+
fakeWindow.location.href = 'http://server/#!/param1=data%27s1&param2=data%27s2';
1033+
$rootScope.$digest();
1034+
expect($location.path()).toBe('/param1=data\'s1&param2=data\'s2');
1035+
1036+
fakeWindow.location.href = 'http://server/#!/data1=anotherValue%27s1&data2=anotherValue%27s2';
1037+
$rootScope.$digest();
1038+
expect($location.path()).toBe('/data1=anotherValue\'s1&data2=anotherValue\'s2');
1039+
});
1040+
});
1041+
1042+
it('should work with apostrophes in url with history and no html5', function() {
1043+
setup({
1044+
history: true,
1045+
html5Mode: false
1046+
});
1047+
inject(function($rootScope, $location) {
1048+
fakeWindow.location.href = 'http://server/#!/param1=data%27s1&param2=data%27s2';
1049+
$rootScope.$digest();
1050+
expect($location.path()).toBe('/param1=data\'s1&param2=data\'s2');
1051+
fakeWindow.location.href = 'http://server/#!/data1=anotherValue%27s1&data2=anotherValue%27s2';
1052+
$rootScope.$digest();
1053+
expect($location.path()).toBe('/data1=anotherValue\'s1&data2=anotherValue\'s2');
1054+
});
1055+
});
1056+
1057+
it('should work with apostrophes in url with history and html5', function() {
1058+
setup({
1059+
history: true,
1060+
html5Mode: true
1061+
});
1062+
inject(function($rootScope, $location) {
1063+
fakeWindow.location.href = 'http://server/param1=data%27s1&param2=data%27s2';
1064+
$rootScope.$digest();
1065+
expect($location.path()).toBe('/param1=data\'s1&param2=data\'s2');
1066+
fakeWindow.location.href = 'http://server/data1=anotherValue%27s1&data2=anotherValue%27s2';
1067+
$rootScope.$digest();
1068+
expect($location.path()).toBe('/data1=anotherValue\'s1&data2=anotherValue\'s2');
1069+
});
1070+
});
10041071
});
10051072

1073+
10061074
it('should not reload the page on every $digest when the page will be reloaded due to url rewrite on load', function() {
10071075
setup({
10081076
history: false,

0 commit comments

Comments
 (0)