scroll: add $ionicScrollDelegate with new pattern

Addresses #877
This commit is contained in:
Andy Joslin
2014-03-24 15:56:23 -06:00
parent b1a7c1990a
commit c1d2571d5e
12 changed files with 437 additions and 152 deletions

View File

@@ -27,17 +27,28 @@ describe('$ionicScroll Controller', function() {
});
}
it('should set $scope.$ionicScrollController by default', function() {
setup()
expect(scope.$ionicScrollController).toBe(ctrl);
});
it('should register with no handle', inject(function($ionicScrollDelegate) {
spyOn($ionicScrollDelegate, '_registerInstance');
var el = setup();
expect($ionicScrollDelegate._registerInstance)
.toHaveBeenCalledWith(ctrl, undefined);
}));
it('should set options.controllerBind to ctrl', function() {
setup({
controllerBind: 'something'
it('should register with given handle and deregister on destroy', inject(function($ionicScrollDelegate) {
var deregisterSpy = jasmine.createSpy('deregister');
spyOn($ionicScrollDelegate, '_registerInstance').andCallFake(function() {
return deregisterSpy;
});
expect(scope.something).toBe(ctrl);
});
setup({
delegateHandle: 'something'
});
expect($ionicScrollDelegate._registerInstance)
.toHaveBeenCalledWith(ctrl, 'something');
expect(deregisterSpy).not.toHaveBeenCalled();
scope.$destroy();
expect(deregisterSpy).toHaveBeenCalled();
}));
it('should set bouncing to option if given', function() {
spyOn(ionic.Platform, 'isAndroid');