Unit testing controller which injects $ionicSlideBoxDelegate


I’m struggling to mock a ionicSlideBoxDelegate as I’m obtaining it from the $getByHandle method. So the problem I’m having is when I’m attempting to mock this part of the test to determine if the .next method is called correctly and increments the currentIndex of the slide box I’m receiving the following error TypeError: 'undefined' is not an object (evaluating 'slides.length')

I’m compiling the directive as follows:

element = $compile('<ion-slide-box delegate-handle="article-viewer"><ion-slide ng-repeat="article in articles"></ion-slide></ion-slide-box>')(scope);


articles is an array comprising of 2 objects, what those objects are is irrelevant.

Here’s my test:

it('should go to the next slide', inject(function ($ionicSlideBoxDelegate) {
    var delegate = $ionicSlideBoxDelegate.$getByHandle('article-viewer');

I’ve tried running .update() before .next() but still the same issue, any ideas?