I am currently troubleshooting a unit test for my user interface router routes, specifically focusing on the issue I encountered with the test not passing successfully.
Within my test script, when checking the value of $state.current.name
, it returns 'frontpage' instead of 'items', which is unexpected as I have configured the state to be 'items'.
it('should change state to items', function() {
$state.go('items');
$rootScope.$digest();
expect($state.current.name).toBe('items');
})
The routing setup is as follows:
$urlRouterProvider.otherwise("/");
$stateProvider
.state('items', {
url: '/items',
templateUrl: 'js/modules/items/partials/items.html',
controller: 'ItemsController',
resolve: {
items : ['ItemService', '$q', function(ItemService, $q) {
var defer = $q.defer();
ItemService.getItems().success(function(data) {
defer.resolve(data);
});
return defer.promise;
}]
}
})
.state('frontpage', {
url: '/',
template: 'Frontpage'
})
I am puzzled as to why the state remains at 'frontpage' even after initiating the state transition with $state.go('items')
. Any insights on this discrepancy would be greatly appreciated.