diff options
Diffstat (limited to 'test/ng/locationSpec.js')
| -rw-r--r-- | test/ng/locationSpec.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index f23965f8..ff823d30 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -4,6 +4,8 @@ describe('$location', function() { var url; + beforeEach(module(provideLog)); + afterEach(function() { // link rewriting used in html5 mode on legacy browsers binds to document.onClick, so we need // to clean this up after each test. @@ -1401,6 +1403,32 @@ describe('$location', function() { dealoc($rootElement); }); }); + + it('should always return the new url value via path() when $locationChangeStart event occurs regardless of cause', + inject(function($location, $rootScope, $browser, log) { + var base = $browser.url(); + + $rootScope.$on('$locationChangeStart', function() { + log($location.path()); + }); + + // change through $location service + $rootScope.$apply(function() { + $location.path('/myNewPath'); + }); + + // reset location + $rootScope.$apply(function() { + $location.path(''); + }); + + // change through $browser + $browser.url(base + '#/myNewPath'); + $browser.poll(); + + expect(log).toEqual(['/myNewPath', '/', '/myNewPath']); + }) + ); }); describe('LocationHtml5Url', function() { |
