Unit test ionicActionSheet


#1

Hi guys, i was wondering if any of you know a good way to unit test ionicActionSheet. Here is a simple action sheet and the main thing i want to test is the click functions associated with each buttons, if any of you have some idea of how i can access the functions that would be great. And by the way i’m using Karma + Jasmine for testing

var hideSheet = $ionicActionSheet.show({
    buttons: [
        {
            text: translate('TEST-2'),
            click: function() {
                SomeService.functionCall;
                $state.go('app.something-1');
        }
    },
    {
        text: translate('EDIT'),
        click: function() {
            $state.go('app.something-2');
            }
        }
    ],
    destructiveText: translate('TEST-1'),
    titleText: title,
    cancelText: translate('LOG_CANCEL'),
    cancel: function() {
    },
    buttonClicked: function(index, button) {
        button.click();
        return true;
    },
    destructiveButtonClicked: function(){
        $scope.example();
        return true;
    }
});

#2

Nobody ? If any of you have any idea it would be great


#3

Since this is Unit Test, your should test your functions separately. Put then in a service or something and test them individually.
Otherwise, your should do integration/e2e tests to take care of it.

I don’t think you need to test that the function is called, that’s the job of $ionicActionSheet tests. If the function is not called, it would mean that $ionicActionSheet itself is broken.