This is the route:
angular.module('ps.auth')
.config(function ($stateProvider) {
$stateProvider.state('login', {
url: '/login/:username',
views: {
'content': {
templateUrl: 'auth/login.html',
controller: 'AuthController'
}
},
authNotRequired: true
})
.state('logout', {
url: '/logout',
controller: 'LogoutCtrl',
authNotRequired: true
});
});
'use strict';
describe('ps.auth', function () {
var $state, $templateCache, $rootScope, $injector, $location;//, $timeout;
function mockTemplate(templateRoute, tmpl) {
$templateCache.put(templateRoute, tmpl || templateRoute);
}
function goTo(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_;
}));
describe('path', function () {
function goTo(url) {
$location.url(url);
$rootScope.$digest();
}
describe('/login', function () {
beforeEach(mockTemplate.bind(null, 'auth/login.html'));
// Having the parameter done pass into this function below to avoid
// for block signature will trigger async behavior
it('should go to the login state', function (done) {
goTo('/login');
// $timeout.flush();
console.log('****** This is $state.current', $state.current);
expect($state.current.name).toEqual('login');
done();
});
});
});
});
Ran the unit test and always got this error message: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. Any suggestion how to fix this issue.
Aucun commentaire:
Enregistrer un commentaire