I am trying to write Unit-Tests for the following use case:
A http-request responds with an unathorized http-status(401) -> change state to login
The Problem is, that I dont even get the correct $state parameter injected into my test.
describe('Login: ', function() {
beforeEach(module('myapp'));
function mockTemplate(templateRoute, tmpl) {
$templateCache.put(templateRoute, tmpl || templateRoute);
}
describe('On HTTP 401', function(){
var state;
beforeEach(function(){
mockTemplate.bind('components/splitapp/splitappView.html', '')
mockTemplate.bind('components/splitappMaster/splitappMasterView.html', '')
mockTemplate.bind('components/splitappDetail/splitappDetailView.html', '')
mockTemplate.bind('components/splitapp/offcanvasMenu.html', '')
})
it('Should go to login-state', inject(function($state, $location){
console.log($location.url())
$state.go("splitapp")
console.log($state.current)
expect($state.is('splitapp')).toEqual(true);
}))
})
});
After $state.go the state should be splitapp, which is defined correctly in the router config. Heres my testrunner output
LOG: ''
LOG: Object{name: '', url: '^', views: null, abstract: true}
Chrome 40.0.2214 (Mac OS X 10.10.2) Login: On HTTP 401 Should go to login-
state FAILED
Expected false to equal true.
Error: Expected false to equal true.
Thanks for your help.
Aucun commentaire:
Enregistrer un commentaire