I use angularjs v1.2.20, angular-mock v1.2.19, ui.route v0.2.10. For the
next route I can't get working test. I have one route:
angular.module('application')
.config(function ($stateProvider, $urlRouterProvider) {
'use strict';
function getTemplate(templateName) {
return 'modules/' + templateName + '/template.html';
}
$urlRouterProvider.
otherwise('/login');
$stateProvider
.state('main', {
abstract: true,
views: {
'': {
templateUrl: getTemplate('layouts/public')
},
'footer@main': {
templateUrl: getTemplate('footer'),
controller: 'FooterController'
}
}
})
.state('main.login', {
url: '/login',
templateUrl: getTemplate('login'),
controller: 'LoginController'
});
}
);
and one test for that route:
describe('Routers', function () {
"use strict";
var state, rootScope;
beforeEach(function () {
module('application');
inject(function ($rootScope, $state) {
rootScope = $rootScope;
state = $state;
});
});
describe('login state', function () {
beforeEach(inject(function ($httpBackend) {
$httpBackend.expectGET('modules/layouts/public/template.html')
.respond(200, 'main HTML');
$httpBackend.expectGET('modules/footer/template.html')
.respond(200, 'main HTML');
$httpBackend.expectGET('modules/login/template.html')
.respond(200, 'main HTML');
}));
it('main.login state controller should be LoginController', function ()
{
state.go('main.login');
rootScope.$digest();
console.log(state.current);
expect(state.current.controller).toBe('LoginController')
});
})
});
but in console I see such log:
Object{name: '', url: '^', views: null, abstract: true}
Expected undefined to be 'LoginController'.
Error: Expected undefined to be 'LoginController'.
How can I test that is exactly LoginController for 'main.login' state ?
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.