I've written tests for an AngularJS application's routes before. For instance, here's part of one I wrote:
describe('Routes', function () {
it('should map default route to home controller', function () {
module('myapp');
inject(function ($route) {
expect($route.routes['/'].controller).toBe('HomeCtrl');
expect($route.routes['/'].templateUrl).toEqual('/static/templates/home.html');
});
});
});
However, I'm currently working on an Ionic app, and it uses the ui-router
from angular-ui
, rather than Angular's default routes, so it uses $state
rather than $route
.
My question is, is there a similar way I can test using $state
? I couldn't find anything likely-sounding in the documentation
$state.$current.self
It has propertiescontroller
,template
,name
,url
if they defined for this state – Kirill Slatin Aug 5 at 9:03$state
in the debugger, but calling$state.go()
in the test doesn't seem to do anything. I figure I may be missing something. – Matthew Daly Aug 5 at 9:50$scope.
or$rootScope.
call$apply()
or$digest();
– Kirill Slatin Aug 5 at 17:26