From c648fee5c2c46cbd2ea8b5bd4cec8005f182db1c Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 31 Jan 2011 23:25:42 -0800 Subject: fix $location to handle updates to empty hash well --- test/servicesSpec.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test') diff --git a/test/servicesSpec.js b/test/servicesSpec.js index 02e874fe..f7151dbc 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -298,6 +298,12 @@ describe("service", function(){ $location.update('http://www.angularjs.org/index.php#'); expect($location.href).toEqual('http://www.angularjs.org/index.php'); }); + + it('should clear hash when updating to hash-less URL', function() { + $location.update('http://server'); + expect($location.href).toBe('http://server'); + expect($location.hash).toBe(''); + }); }); @@ -320,6 +326,17 @@ describe("service", function(){ expect($location.hashSearch).toEqual({a: 'b'}); expect($location.hashPath).toEqual('path'); }); + + it('should update href and hash when updating to empty string', function() { + $location.updateHash(''); + expect($location.href).toBe('http://server'); + expect($location.hash).toBe(''); + + scope.$eval(); + + expect($location.href).toBe('http://server'); + expect($location.hash).toBe(''); + }); }); }); -- cgit v1.2.3