diff options
| author | Rado Kirov | 2012-09-21 18:57:22 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-11-26 23:21:02 +0100 |
| commit | a32bc40fd75ca46e3581ad7a6e3a24a31df6e266 (patch) | |
| tree | 7f913cd56637c896e23b7b830d2db3ade0483f12 /test/ng/locationSpec.js | |
| parent | cfe13b5dac3d1260400bb55194f2bc27169fd360 (diff) | |
| download | angular.js-a32bc40fd75ca46e3581ad7a6e3a24a31df6e266.tar.bz2 | |
fix($location): reset $location.$$replace with every watch call
Closes #1111
Diffstat (limited to 'test/ng/locationSpec.js')
| -rw-r--r-- | test/ng/locationSpec.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index 17ae13f3..cb3372a3 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -447,6 +447,29 @@ describe('$location', function() { expect($browserUrl).toHaveBeenCalledOnce(); expect($browserUrl.mostRecentCall.args).toEqual(['http://new.com/a/b#!/n/url', true]); + expect($location.$$replace).toBe(false); + })); + + + it('should always reset replace flag after running watch', inject(function($rootScope, $location) { + // init watches + $location.url('/initUrl'); + $rootScope.$apply(); + + // changes url but resets it before digest + $location.url('/newUrl').replace().url('/initUrl'); + $rootScope.$apply(); + expect($location.$$replace).toBe(false); + + // set the url to the old value + $location.url('/newUrl').replace(); + $rootScope.$apply(); + expect($location.$$replace).toBe(false); + + // doesn't even change url only calls replace() + $location.replace(); + $rootScope.$apply(); + expect($location.$$replace).toBe(false); })); |
