feat($ionicScrollDelegate): add scrollTo(left,top,animate) to delegate

Also moves $ionicScrollDelegate.register to $ionicScroll controller,
and makes `<scroll>` directive be registered with $ionicScrollDelegate.
This commit is contained in:
Andy Joslin
2014-02-11 13:32:03 -05:00
parent 801d2d7b77
commit c119498d1b
10 changed files with 158 additions and 85 deletions

View File

@@ -1,6 +1,6 @@
describe('$ionicScroll Controller', function() {
beforeEach(module('ionic.ui.scroll'));
beforeEach(module('ionic'));
var scope, ctrl, timeout;
function setup(options) {
@@ -41,6 +41,12 @@ describe('$ionicScroll Controller', function() {
expect(ctrl.scrollView.run).toHaveBeenCalled();
});
it('should register with $ionicScrollDelegate', inject(function($ionicScrollDelegate) {
spyOn($ionicScrollDelegate, 'register');
setup();
expect($ionicScrollDelegate.register).toHaveBeenCalledWith(scope, ctrl.$element, ctrl.scrollView);
}));
it('should not setup if no child .scroll-refresher', function() {
setup();
timeout.flush();
@@ -70,7 +76,6 @@ describe('$ionicScroll Controller', function() {
});
scope.onRefresh = jasmine.createSpy('onRefresh');
scope.$parent.$broadcast = jasmine.createSpy('$broadcast');
timeout.flush();
var refresher = ctrl.refresher;
@@ -87,13 +92,11 @@ describe('$ionicScroll Controller', function() {
expect(refresher.classList.contains('refreshing')).toBe(false);
expect(scope.onRefresh).not.toHaveBeenCalled();
expect(scope.$parent.$broadcast).not.toHaveBeenCalledWith('scroll.onRefresh');
doneCb();
expect(refresher.classList.contains('active')).toBe(false);
expect(refresher.classList.contains('refreshing')).toBe(true);
expect(scope.onRefresh).toHaveBeenCalled();
expect(scope.$parent.$broadcast).toHaveBeenCalledWith('scroll.onRefresh');
});
});