diff options
| author | Thibault Leruitte | 2013-03-08 14:53:54 +0100 |
|---|---|---|
| committer | Igor Minar | 2013-03-11 15:26:38 -0700 |
| commit | 9befe37014141fbfdf0cded318d28322fc058c13 (patch) | |
| tree | c33159cda36edfe1ec1528570d7a359516cc5834 /test/ng/locationSpec.js | |
| parent | e88d6179c3a6a137e75fa09de906fc83c6515db2 (diff) | |
| download | angular.js-9befe37014141fbfdf0cded318d28322fc058c13.tar.bz2 | |
fix($location): correctly rewrite html5 url to hashbang url
In situations where path() matched basepath and we needed to
convert from html5 url to hashbang url, the $location service
considered the url to be already rewritten, which resulted in
an error.
Diffstat (limited to 'test/ng/locationSpec.js')
| -rw-r--r-- | test/ng/locationSpec.js | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index cb3372a3..c40d5323 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -549,6 +549,16 @@ describe('$location', function() { } ); }); + + it('should correctly convert html5 url with path matching basepath to hashbang url', function () { + initService(true, '!', false); + inject( + initBrowser('http://domain.com/base/index.html', '/base/index.html'), + function($browser, $location) { + expect($browser.url()).toBe('http://domain.com/base/index.html#!/index.html'); + } + ); + }); }); @@ -1209,7 +1219,7 @@ describe('$location', function() { ); - it('should listen on click events on href and prevent browser default in hashbang mode', function() { + it('should listen on click events on href and prevent browser default in hashbang mode', function() { module(function() { return function($rootElement, $compile, $rootScope) { $rootElement.html('<a href="http://server/#/somePath">link</a>'); @@ -1253,20 +1263,21 @@ describe('$location', function() { inject(function($location, $rootScope, $browser, $rootElement) { var log = '', - link = $rootElement.find('a'); + link = $rootElement.find('a'), + browserUrlBefore = $browser.url(); $rootScope.$on('$locationChangeStart', function(event) { event.preventDefault(); log += '$locationChangeStart'; }); $rootScope.$on('$locationChangeSuccess', function() { - throw new Error('after cancelation in html5 mode'); + throw new Error('after cancellation in html5 mode'); }); browserTrigger(link, 'click'); expect(log).toEqual('$locationChangeStart'); - expect($browser.url()).toEqual('http://server/'); + expect($browser.url()).toBe(browserUrlBefore); dealoc($rootElement); }); |
