Skip to content

Commit 91f243b

Browse files
dmartresjbedard
authored andcommitted
test($browser): add tests for apostrophes in urls
1 parent 2c7aa68 commit 91f243b

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
@@ -879,8 +879,76 @@ describe('browser', function() {
879879
});
880880
});
881881

882+
883+
it('should work with apostrophes in url with no history support, no html5Mode', function() {
884+
setup({
885+
history: false,
886+
html5Mode: false
887+
});
888+
889+
inject(function($rootScope, $location) {
890+
/* all aphostrofes in url should be replaced */
891+
fakeWindow.location.href = 'http://server/#!/param1=data%27s1&param2=data%27s2';
892+
$rootScope.$digest();
893+
expect($location.path()).toBe('/param1=data\'s1&param2=data\'s2');
894+
895+
/* validate that location.href could be updated */
896+
fakeWindow.location.href = 'http://server/#!/data1=anotherValue%27s1&data2=anotherValue%27s2';
897+
$rootScope.$digest();
898+
expect($location.path()).toBe('/data1=anotherValue\'s1&data2=anotherValue\'s2');
899+
});
900+
});
901+
902+
it('should work with apostrophes in url with html5Mode and no history support', function() {
903+
setup({
904+
history: false,
905+
html5Mode: true
906+
});
907+
908+
inject(function($rootScope, $location) {
909+
910+
fakeWindow.location.href = 'http://server/#!/param1=data%27s1&param2=data%27s2';
911+
$rootScope.$digest();
912+
expect($location.path()).toBe('/param1=data\'s1&param2=data\'s2');
913+
914+
fakeWindow.location.href = 'http://server/#!/data1=anotherValue%27s1&data2=anotherValue%27s2';
915+
$rootScope.$digest();
916+
expect($location.path()).toBe('/data1=anotherValue\'s1&data2=anotherValue\'s2');
917+
});
918+
});
919+
920+
it('should work with apostrophes in url with history and no html5', function() {
921+
setup({
922+
history: true,
923+
html5Mode: false
924+
});
925+
inject(function($rootScope, $location) {
926+
fakeWindow.location.href = 'http://server/#!/param1=data%27s1&param2=data%27s2';
927+
$rootScope.$digest();
928+
expect($location.path()).toBe('/param1=data\'s1&param2=data\'s2');
929+
fakeWindow.location.href = 'http://server/#!/data1=anotherValue%27s1&data2=anotherValue%27s2';
930+
$rootScope.$digest();
931+
expect($location.path()).toBe('/data1=anotherValue\'s1&data2=anotherValue\'s2');
932+
});
933+
});
934+
935+
it('should work with apostrophes in url with history and html5', function() {
936+
setup({
937+
history: true,
938+
html5Mode: true
939+
});
940+
inject(function($rootScope, $location) {
941+
fakeWindow.location.href = 'http://server/param1=data%27s1&param2=data%27s2';
942+
$rootScope.$digest();
943+
expect($location.path()).toBe('/param1=data\'s1&param2=data\'s2');
944+
fakeWindow.location.href = 'http://server/data1=anotherValue%27s1&data2=anotherValue%27s2';
945+
$rootScope.$digest();
946+
expect($location.path()).toBe('/data1=anotherValue\'s1&data2=anotherValue\'s2');
947+
});
948+
});
882949
});
883950

951+
884952
it('should not reload the page on every $digest when the page will be reloaded due to url rewrite on load', function() {
885953
setup({
886954
history: false,

0 commit comments

Comments
 (0)