I am getting a hard time to resolve mocha chai test case for angular js configuration file .
angular.module(\'myApp.myModule\', []).config(function ($stateProvid
I did it like
it('should load the page.', inject(function ($state) {
var state = $state.get('selectLine');
assert.isDefined(state.templateUrl());
expect(state.templateUrl()).to.equal('scripts/select-line-module/views/select-line.html');
}));
This works for me
What you can do is to inject $location
and $route
service into your test. Setup a whenGET to intercept the actual request and then check the $location
and $route
configuration after the transition is complete. I did something similar earlier
it("should load the page.", inject(function ($rootScope, $location, $route, $httpBackend) {
$httpBackend.whenGET("scripts/my-module/views/my-module.html").respond("<div/>");
$location.path("/myModule");
$rootScope.$digest();
expect($location.path()).toBe("/myModule");
}));
I was using $route
service you would require $state
service.