aboutsummaryrefslogtreecommitdiffstats
path: root/test/service/locationSpec.js
diff options
context:
space:
mode:
authorVojta Jina2011-06-22 19:57:22 +0200
committerVojta Jina2011-09-08 20:36:33 +0200
commit988ed451b508b9d7ea4690b150993ec62d8a3743 (patch)
tree70c8a2200ae4b80da04b6eba239a07962f209638 /test/service/locationSpec.js
parentfc2f188d4d8f06aab31979b293d95580e19cbdf1 (diff)
downloadangular.js-988ed451b508b9d7ea4690b150993ec62d8a3743.tar.bz2
feat($browser): jQuery style url method, onUrlChange event
This is just basic implementation of $browser.url, $browser.onUrlChange methods: $browser.url() - returns current location.href $browser.url('/new') - set url to /new If supported, history.pushState is used, location.href property otherwise. $browser.url('/new', true) - replace current url with /new If supported, history.replaceState is used, location.replace otherwise. $browser.onUrlChange is only fired when url is changed from the browser: - user types into address bar - user clicks on back/forward button - user clicks on link It's not fired when url is changed using $browser.url() Breaks Removed $browser.setUrl(), $browser.getUrl(), use $browser.url() Breaks Removed $browser.onHashChange(), use $browser.onUrlChange()
Diffstat (limited to 'test/service/locationSpec.js')
-rw-r--r--test/service/locationSpec.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/test/service/locationSpec.js b/test/service/locationSpec.js
index 5839b0b6..a137149d 100644
--- a/test/service/locationSpec.js
+++ b/test/service/locationSpec.js
@@ -32,24 +32,24 @@ describe('$location', function() {
it('should update location when browser url changed', function() {
var origUrl = $location.href;
- expect(origUrl).toEqual($browser.getUrl());
+ expect(origUrl).toEqual($browser.url());
var newUrl = 'http://somenew/url#foo';
- $browser.setUrl(newUrl);
+ $browser.url(newUrl);
$browser.poll();
expect($location.href).toEqual(newUrl);
});
it('should update browser at the end of $eval', function() {
- var origBrowserUrl = $browser.getUrl();
+ var origBrowserUrl = $browser.url();
$location.update('http://www.angularjs.org/');
$location.update({path: '/a/b'});
expect($location.href).toEqual('http://www.angularjs.org/a/b');
- expect($browser.getUrl()).toEqual('http://www.angularjs.org/a/b');
+ expect($browser.url()).toEqual('http://www.angularjs.org/a/b');
$location.path = '/c';
scope.$digest();
- expect($browser.getUrl()).toEqual('http://www.angularjs.org/c');
+ expect($browser.url()).toEqual('http://www.angularjs.org/c');
});