aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/locationSpec.js
diff options
context:
space:
mode:
authorRado Kirov2012-09-21 18:57:22 -0700
committerIgor Minar2012-11-26 23:24:39 +0100
commitfc781560a341c804b02c7efd30c6d3010206401c (patch)
tree48de9757da5982e49eab1d79b58bd985a3726a27 /test/ng/locationSpec.js
parentc9199ee6634af6b960524d91bdae706860a49d0c (diff)
downloadangular.js-fc781560a341c804b02c7efd30c6d3010206401c.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.js23
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);
}));