USER_FIRST_NAME_KEY,
USER_LAST_NAME_KEY
} from "../../services/auth-service/auth-service";
+import { API_HOST } from "../../common/server-api";
require('jest-localstorage-mock');
expect(localStorage.getItem(API_TOKEN_KEY)).toBe("token");
});
+
+ it('should fire external url to login', () => {
+ const initialState = undefined;
+
+ const location = {
+ href: 'http://localhost:3000',
+ protocol: 'http:',
+ host: 'localhost:3000'
+ };
+
+ global['window'] = { location };
+
+ authReducer(initialState, actions.LOGIN());
+ expect(window.location.href).toBe(
+ `${API_HOST}/login?return_to=${location.protocol}//${location.host}/token`
+ );
+ });
+
+ it('should fire external url to logout', () => {
+ const initialState = undefined;
+
+ const location = {
+ href: 'http://localhost:3000',
+ protocol: 'http:',
+ host: 'localhost:3000'
+ };
+
+ global['window'] = { location };
+
+ authReducer(initialState, actions.LOGOUT());
+ expect(window.location.href).toBe(
+ `${API_HOST}/logout?return_to=${location.protocol}//${location.host}`
+ );
+ });
});
INIT: () => {
const user = authService.getUser();
const token = authService.getApiToken();
- return { user, apiToken: token };
+ return {user, apiToken: token};
},
LOGIN: () => {
authService.login();