- const state = authReducer(initialState, authActions.INIT());
- expect(state).toEqual({
- apiToken: undefined,
- user: undefined
- });
- });
-
- it('should read user and api token from local storage on init if they are there', () => {
- const initialState = undefined;
-
- localStorage.setItem(API_TOKEN_KEY, "token");
- localStorage.setItem(USER_EMAIL_KEY, "test@test.com");
- localStorage.setItem(USER_FIRST_NAME_KEY, "John");
- localStorage.setItem(USER_LAST_NAME_KEY, "Doe");
- localStorage.setItem(USER_UUID_KEY, "uuid");
- localStorage.setItem(USER_OWNER_UUID_KEY, "ownerUuid");
-
- const state = authReducer(initialState, authActions.INIT());
- expect(state).toEqual({
- apiToken: "token",
- user: {
- email: "test@test.com",
- firstName: "John",
- lastName: "Doe",
- uuid: "uuid",
- ownerUuid: "ownerUuid"
- }
- });
- });
-
- it('should store token in local storage', () => {
- const initialState = undefined;
-
- const state = authReducer(initialState, authActions.SAVE_API_TOKEN("token"));
+ const user = {
+ email: "test@test.com",
+ firstName: "John",
+ lastName: "Doe",
+ uuid: "zzzzz-tpzed-xurymjxw79nv3jz",
+ ownerUuid: "ownerUuid",
+ username: "username",
+ prefs: {},
+ isAdmin: false,
+ isActive: true
+ };
+ const state = reducer(initialState, authActions.INIT_USER({ user, token: "token" }));