I am trying to check out some views that use <a ui-sref='someState'>link</a> to communicate with other states in my application. In my tests, I start clicking on these elements as follows:
element.find('a').click()
How can I check if the state is switched to someState ? Using $state in my controller would be easy:
// in my view <a ng-click="goTo('someState')">link</a> // in my controller $scope.goTo = function(s) { $state.go(s) }; // in my tests spyOn($state, 'go'); element.find('a').click() expect($state.go).toHaveBeenCalled()
But when I use ui-sref , I don’t know which object to spy on. How can I verify that my application is in the correct state?
angularjs angular-ui-router jasmine
23tux
source share