Below is the code snippet for a Controller in Angular JS:
describe('Controller: homeCtrl', function () {
beforeEach(module('incident'));
var homeCtrl, $state;
beforeEach(inject(function ($controller, _$state_) {
$state = _$state_;
homeCtrl = $controller('homeCtrl', {$state: $state});
}));
it('should be defined', function () {
expect(homeCtrl).toBeDefined();
});
it('should transition to state', inject(function ($state) {
$state.expectTransitionTo('incidents');
}));
});
When attempting to test $state.go as shown below, an error occurs (refer to attached image):
describe('Controller: homeCtrl', function () {
beforeEach(module('incident'));
var homeCtrl, $state;
beforeEach(inject(function ($controller, _$state_) {
$state = _$state_;
homeCtrl = $controller('homeCtrl', {$state: $state});
}));
it('should transition to state', inject(function ($state) {
$state.expectTransitionTo('incidents');
}));
});
I welcome any suggestions or sample code that demonstrates how to properly test this $state.go functionality.