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

Commit

Permalink
test($browser): add tests for apostrophes in urls
Browse files Browse the repository at this point in the history
  • Loading branch information
dmartres authored and jbedard committed Jul 26, 2017
1 parent b0e5ac6 commit 45c1327
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions test/ng/browserSpecs.js
Expand Up @@ -879,8 +879,76 @@ describe('browser', function() {
});
});


it('should work with apostrophes in url with no history support, no html5Mode', function() {
setup({
history: false,
html5Mode: false
});

inject(function($rootScope, $location) {
/* all aphostrofes in url should be replaced */
fakeWindow.location.href = 'http://server/#!/param1=data%27s1&param2=data%27s2';
$rootScope.$digest();
expect($location.path()).toBe('/param1=data\'s1&param2=data\'s2');

/* validate that location.href could be updated */
fakeWindow.location.href = 'http://server/#!/data1=anotherValue%27s1&data2=anotherValue%27s2';
$rootScope.$digest();
expect($location.path()).toBe('/data1=anotherValue\'s1&data2=anotherValue\'s2');
});
});

it('should work with apostrophes in url with html5Mode and no history support', function() {
setup({
history: false,
html5Mode: true
});

inject(function($rootScope, $location) {

fakeWindow.location.href = 'http://server/#!/param1=data%27s1&param2=data%27s2';
$rootScope.$digest();
expect($location.path()).toBe('/param1=data\'s1&param2=data\'s2');

fakeWindow.location.href = 'http://server/#!/data1=anotherValue%27s1&data2=anotherValue%27s2';
$rootScope.$digest();
expect($location.path()).toBe('/data1=anotherValue\'s1&data2=anotherValue\'s2');
});
});

it('should work with apostrophes in url with history and no html5', function() {
setup({
history: true,
html5Mode: false
});
inject(function($rootScope, $location) {
fakeWindow.location.href = 'http://server/#!/param1=data%27s1&param2=data%27s2';
$rootScope.$digest();
expect($location.path()).toBe('/param1=data\'s1&param2=data\'s2');
fakeWindow.location.href = 'http://server/#!/data1=anotherValue%27s1&data2=anotherValue%27s2';
$rootScope.$digest();
expect($location.path()).toBe('/data1=anotherValue\'s1&data2=anotherValue\'s2');
});
});

it('should work with apostrophes in url with history and html5', function() {
setup({
history: true,
html5Mode: true
});
inject(function($rootScope, $location) {
fakeWindow.location.href = 'http://server/param1=data%27s1&param2=data%27s2';
$rootScope.$digest();
expect($location.path()).toBe('/param1=data\'s1&param2=data\'s2');
fakeWindow.location.href = 'http://server/data1=anotherValue%27s1&data2=anotherValue%27s2';
$rootScope.$digest();
expect($location.path()).toBe('/data1=anotherValue\'s1&data2=anotherValue\'s2');
});
});
});


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

0 comments on commit 45c1327

Please sign in to comment.