diff options
| author | Vojta Jina | 2012-01-12 03:00:34 -0800 |
|---|---|---|
| committer | Vojta Jina | 2012-01-13 01:07:12 -0800 |
| commit | 15fd735793cffe89fdf9662275409cdcdb3e801a (patch) | |
| tree | ce5699ab3375d41cfcffb88ed93236b7ff96a366 /test/service | |
| parent | 985d3d75586a16020d78564753f9b46ec9091929 (diff) | |
| download | angular.js-15fd735793cffe89fdf9662275409cdcdb3e801a.tar.bz2 | |
refactor($autoScroll): rename to $anchorScroll and allow disabling auto scrolling (links)
Now, that we have autoscroll attribute on ng:include, there is no reason to disable the service completely, so $anchorScrollProvider.disableAutoScrolling() means it won't be scrolling when $location.hash() changes.
And then, it's not $autoScroll at all, it actually scrolls to anchor when it's called, so I renamed
it to $anchorScroll.
Diffstat (limited to 'test/service')
| -rw-r--r-- | test/service/anchorScrollSpec.js (renamed from test/service/autoScrollSpec.js) | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/test/service/autoScrollSpec.js b/test/service/anchorScrollSpec.js index 72fc3424..7e4b3aa3 100644 --- a/test/service/autoScrollSpec.js +++ b/test/service/anchorScrollSpec.js @@ -1,4 +1,4 @@ -describe('$autoScroll', function() { +describe('$anchorScroll', function() { var elmSpy; @@ -18,9 +18,9 @@ describe('$autoScroll', function() { } function changeHashAndScroll(hash) { - return function($location, $autoScroll) { + return function($location, $anchorScroll) { $location.hash(hash); - $autoScroll(); + $anchorScroll(); }; } @@ -46,12 +46,6 @@ describe('$autoScroll', function() { return expectScrollingTo(NaN); } - function disableScroller() { - return function($autoScrollProvider) { - $autoScrollProvider.disable(); - }; - } - beforeEach(module(function($provide) { elmSpy = {}; @@ -108,16 +102,6 @@ describe('$autoScroll', function() { expectScrollingTo('id=top'))); - it('should not scroll when disabled', function() { - module(disableScroller()); - inject( - addElements('id=fake', 'a name=fake', 'input name=fake'), - changeHashAndScroll('fake'), - expectNoScrolling() - ); - }); - - describe('watcher', function() { function initLocation(config) { @@ -128,13 +112,19 @@ describe('$autoScroll', function() { } function changeHashTo(hash) { - return function ($location, $rootScope, $autoScroll) { + return function ($location, $rootScope, $anchorScroll) { $rootScope.$apply(function() { $location.hash(hash); }); }; } + function disableAutoScrolling() { + return function($anchorScrollProvider) { + $anchorScrollProvider.disableAutoScrolling(); + }; + } + afterEach(inject(function($document) { dealoc($document); })); @@ -182,7 +172,7 @@ describe('$autoScroll', function() { it('should not scroll when disabled', function() { module( - disableScroller(), + disableAutoScrolling(), initLocation({html5Mode: false, historyApi: false}) ); inject( |
