Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: TT-155 modify test input data
  • Loading branch information
thegreatyamori authored and Angeluz-07 committed Mar 19, 2021
commit 2e6728490cc096d6b59ffcabddbb9a2d6f922d20
8 changes: 4 additions & 4 deletions src/app/modules/user/store/user.actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { User } from '../models/user';
describe('Actions for User', () => {
it('LoadUserSuccess type is UserActionTypes.LOAD_USER_SUCCESS', () => {
const user: User = {
name: 'Jerson Morocho',
email: 'jerson.morocho@ioet.com',
name: 'Unknown Name',
email: 'example@mail.com',
roles: [],
groups: [],
id: 'dd4a1571-b025-41c9-b35f-810841b43134',
tenant_id: 'cc925a5d-9644-4a4f-8d99-0bee49aadd05',
id: 'dummy_id_load',
tenant_id: 'dummy_tenant_id_load',
deleted: ''
};

Expand Down
10 changes: 5 additions & 5 deletions src/app/modules/user/store/user.effects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ describe('UserEffects', () => {
let effects: UserEffects;
let service: UserService;
const userInfo: User = {
name: 'Jerson Morocho',
email: 'jerson.morocho@ioet.com',
name: 'Unknown Name',
email: 'example@mail.com',
roles: [],
groups: [],
id: 'cc925a5d-9644-4a4f-8d99-0bee49aadd05',
id: 'dummy_tenant_id_load',
tenant_id: null,
deleted: null
};
Expand All @@ -37,7 +37,7 @@ describe('UserEffects', () => {
});

it('action type is LOAD_USER_SUCCESS when service is executed successfully', async () => {
const userId = 'dd4a1571-b025-41c9-b35f-810841b43134';
const userId = 'dummy_id_load';
const serviceSpy = spyOn(service, 'loadUser');

actions$ = of(new LoadUser(userId));
Expand All @@ -49,7 +49,7 @@ describe('UserEffects', () => {
});

it('action type is LOAD_USER_FAIL when service fail in execution', async () => {
const userId = 'dd4a1571-b025-41c9-b35f-810841b43134';
const userId = 'dummy_id_load';
const serviceSpy = spyOn(service, 'loadUser');

actions$ = of(new LoadUser(userId));
Expand Down
8 changes: 4 additions & 4 deletions src/app/modules/user/store/user.reducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('userReducer', () => {
}

it('on LoadUser, state equal to initState', () => {
const userId = 'dd4a1571-b025-41c9-b35f-810841b43134';
const userId = 'dummy_id_load';
const action = new LoadUser(userId);
const state = userReducer(initState, action);

Expand All @@ -20,11 +20,11 @@ describe('userReducer', () => {

it('on LoadUserSuccess, userFound is saved in store', () => {
const userFound: User = {
name: 'Jerson Morocho',
email: 'jerson.morocho@ioet.com',
name: 'Unknown Name',
email: 'example@mail.com',
roles: [],
groups: [],
id: 'dd4a1571-b025-41c9-b35f-810841b43134',
id: 'dummy_id_load',
tenant_id: null,
deleted: null
};
Expand Down
8 changes: 4 additions & 4 deletions src/app/modules/user/store/user.selectors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { User } from '../models/user';

describe('UserSelectors', () => {
const userInfo: User = {
name: 'Jerson Morocho',
email: 'jerson.morocho@ioet.com',
name: 'Unknown Name',
email: 'example@mail.com',
roles: [],
groups: [],
id: 'cc925a5d-9644-4a4f-8d99-0bee49aadd05',
id: 'dummy_tenant_id_load',
tenant_id: null,
deleted: null
};

it('should select user info', () => {
const result = getUserInfo.projector(userInfo);

expect(userInfo.email).toEqual('jerson.morocho@ioet.com');
expect(userInfo.email).toEqual('example@mail.com');
});

});
4 changes: 3 additions & 1 deletion src/app/modules/user/store/user.selectors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { createFeatureSelector, createSelector } from '@ngrx/store';
import { User } from '../models/user';

const getUserState = createFeatureSelector<any>('user');

export const getUserInfo = createSelector(getUserState, (state: any) => state);
export const getUserInfo = createSelector(getUserState, (state: User) => state);
export const getUserGroups = createSelector(getUserState, (state: User) => state.groups);