Here is my test :
'use strict';
describe('ps.authentication', function () {
var $state, $templateCache, $rootScope, $injector, $location, $timeout;
function mockTemplate(templateRoute, tmpl) {
$templateCache.put(templateRoute, tmpl || templateRoute);
}
function goTo(url) {
console.log('************** 2222 goTo - url = ', url);
$location.url(url);
$rootScope.$digest();
}
beforeEach(module('ui.router'));
beforeEach(inject(function (_$state_, _$templateCache_, _$location_, _$rootScope_, _$injector_) {
$state = _$state_;
$templateCache = _$templateCache_;
$location = _$location_;
$rootScope = _$rootScope_;
$injector = _$injector_;
inject(function ($injector) {
$timeout = $injector.get('$timeout');
});
}));
describe('path', function () {
function goTo(url) {
$location.url(url);
$rootScope.$digest();
}
describe('/login', function () {
beforeEach(mockTemplate.bind(null, 'auth/login.html'));
it('should go to the login state 33', function () {
goTo('/login');
$timeout.flush();
console.log('****** This is $state.current 888', $state.current);
expect($state.current.name).toEqual('');
});
});
});
});
and Here is my router
angular.module('ps.authentication')
.config(function ($stateProvider) {
$stateProvider.state('login', {
url: '/login',
views: {
'content': {
templateUrl: 'auth/login.html',
controller: 'AuthController'
}
},
authNotRequired: true
})
.state('logout', {
url: '/logout',
controller: 'LogoutCtrl',
authNotRequired: true
});
});
Ran the test (grunt test) and got this error message: 01 08 2016 16:50:35.169:INFO [Chrome 51.0.2704 (Mac OS X 10.9.5)]: Connected on socket /#9xB2QxXBGlGLGThUAAAA with id manual-5329 LOG: '****** This is $state.current 888', Object{name: '', url: '^', views: null, abstract: true} Chrome 51.0.2704 (Mac OS X 10.9.5) ps.authentication path /login should go to the login state 33 FAILED Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. Chrome 51.0.2704 (Mac OS X 10.9.5): Executed 133 of 133 (1 FAILED) (5.235 secs / 5.2 secs) Warning: Task "karma:unit" failed. Use --force to continue.
Any idea what was wrong here and how to fix it. -k
Aucun commentaire:
Enregistrer un commentaire