USER_FIRST_NAME_KEY,
USER_LAST_NAME_KEY
} from "../../services/auth-service/auth-service";
+import { API_HOST } from "../../common/api/server-api";
-require('jest-localstorage-mock');
+import 'jest-localstorage-mock';
describe('auth-reducer', () => {
beforeAll(() => {
expect(localStorage.getItem(API_TOKEN_KEY)).toBe("token");
});
+
+ it('should fire external url to login', () => {
+ const initialState = undefined;
+ window.location.assign = jest.fn();
+ authReducer(initialState, actions.LOGIN());
+ expect(window.location.assign).toBeCalledWith(
+ `${API_HOST}/login?return_to=${window.location.protocol}//${window.location.host}/token`
+ );
+ });
+
+ it('should fire external url to logout', () => {
+ const initialState = undefined;
+ window.location.assign = jest.fn();
+ authReducer(initialState, actions.LOGOUT());
+ expect(window.location.assign).toBeCalledWith(
+ `${API_HOST}/logout?return_to=${location.protocol}//${location.host}`
+ );
+ });
});