I have been trying to write a test to check for a redirect page from a backend api. I am expecting a 401 redirect to a login view however the tests show the page I should redirect to if I am already logged in.
I can only assume that the logged in view has already been placed in the $location.path before the call to the api and then the response is coming back after the test has finished. Is there any way to test this or am I on the right track.
My test code is:
window.jQueryFunction('.loginButton', 'click');
expect(browser().location().url()).toBe('/Login');
in my app.js file I test for the 401 using angular event broadcasts
$rootScope.$on('event: auth-loginRequired', function() {
window.location = '/login'
});
can someone tell me if I am in the right ball park or am I way off mark here.