describe('Ionic Scroll Directive', function() { var compile, element, scope; beforeEach(module('ionic')); beforeEach(inject(function($compile, $rootScope, $timeout, $window) { compile = $compile; scope = $rootScope; timeout = $timeout; window = $window; ionic.Platform.setPlatform('Android'); spyOn(ionic.Platform, 'ready').andCallFake(function(cb) { cb(); }); })); it('passes delegateHandle attribute', function() { var element = compile('')(scope); expect(element.controller('$ionicScroll')._scrollViewOptions.delegateHandle) .toBe('handleThis'); }); it('has $onScroll (used by $ionicScrollController)', function() { element = compile('')(scope); scope = element.scope(); scope.foo = jasmine.createSpy('foo'); scope.$apply(); expect(typeof scope.$onScroll).toBe('function'); expect(scope.foo).not.toHaveBeenCalled(); scope.$onScroll(); expect(scope.foo).toHaveBeenCalled(); }); it('Has scroll-view class', function() { element = compile('')(scope); expect(element.hasClass('scroll-view')).toBe(true); }); it('should add padding classname', function() { element = compile('')(scope); scope.$apply(); expect(element.children().eq(0).hasClass('padding')).toEqual(true); var scrollElement = element.find('.scroll'); expect(scrollElement.hasClass('padding')).toEqual(true); }); it('Should set start x and y', function() { element = compile('')(scope); scope.$apply(); var scrollView = element.controller('$ionicScroll').scrollView; var vals = scrollView.getValues(); expect(vals.left).toBe(100); expect(vals.top).toBe(300); }); });