describe('ionNavButtons directive', function() { beforeEach(module('ionic', function($compileProvider) { $compileProvider.directive('needsScroll', function() { return { //Test if the buttons are 'children of ionScroll' when compiled require: '^$ionicScroll', link: function(scope, element, attrs, ctrl) { element.data('scrollCtrl', ctrl); } }; }); })); beforeEach(function() { ionic.requestAnimationFrame = function(cb) { cb(); }; }); function setup(side, tpl) { var el; inject(function($compile, $rootScope) { el = $compile('
' + '' + '' + '' + '' + (tpl || '') + '' + '' + '' + '
')($rootScope.$new()); $rootScope.$apply(); }); return el; } it('should add buttons to left side by default', function() { var el = setup(null, ''); expect(jqLite(el[0].querySelector('ion-content')).children().scope().$id) .toBe(jqLite(el[0].querySelector('.left-buttons button')).scope().$id); //Test if the button was compiled able to access the parents of ion-nav-buttons var scrollCtrl = el.find('ion-content').controller('$ionicScroll'); expect(scrollCtrl).toBeTruthy(); expect(el.find('button[needs-scroll]').data('scrollCtrl')).toBe(scrollCtrl); }); it('should not enter if button is destroyed before raf', function() { var rafCb; ionic.requestAnimationFrame = function(cb) { rafCb = cb; }; var el = setup('left', '