vendredi 20 février 2015

Unit testing if statement based on $state.includes

I am trying to unit test the init function of this controller.I cannot find a way of doing this and keep getting the error



TypeError: 'undefined' is not a function (evaluating '$state.includes('profile.details')')



I have tried mocking the state as a string and using transitionTo, has anyone else found a way of testing includes for states?



var init = function () {
$scope.global = global;
$scope.partialViews = {
personForm: "/app/users/views/details/_personForm.html",
passwordForm: "/app/users/views/details/_passwordForm.html"
};

if (!$state.includes('profile.details') && !$state.includes('profile.organizations')) {
if (global.activeProfile.defaultOrganizationId) {
$state.go("dashboard.notifications", { orgId: global.activeProfile.defaultOrganizationId });
} else {
$state.go("profile.organizations");
}
}
};

Aucun commentaire:

Enregistrer un commentaire