I'm trying to write a test for an Angular app using ui-router similar to that suggested by http://ift.tt/1Dr7N0u.
it('should transition to state', inject(function($rootScope, $state, $log) {
$rootScope.$on('$stateChangeError', function(ev, toState, toParams, fromState, fromParams, error) {
$log.error('$stateChangeError: ', error);
});
$rootScope.$on('$stateNotFound', function(ev, toState, toParams, fromState, fromParams, error) {
$log.error('$stateNotFound: ', error);
});
var caseId = 1;
$state.go('case.summary', { id: caseId }, { notify: true, reload: true });
$rootScope.$digest();
$log.debug('$state.current.name: ' + $state.current.name);
expect($state.current.name).toEqual('case.summary'); // fails
expect($state.is('case.summary', { id: caseId })).toBeTruthy(); // fails
}));
But this test fails.
summary section ✓ should respond to URL LOG LOG: 'debug: caseSvc.get, url: ,http://ift.tt/1Dr7KC4' LOG LOG: 'debug: $state.current.name: ' ✗ should transition to state Expected '' to equal 'case.summary'.
Nevertheless, this test succeeds:
it('should respond to URL', inject(function($state) {
expect($state.href('case.summary', { id: 1 })).toEqual('#/cases/1/summary');
}));
Currently trying to trace this in the Chrome debugger.
I'm pretty stumped at this point.
Aucun commentaire:
Enregistrer un commentaire