Skip to content
Merged
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
TT-111 fix: add a test to check new model of users
  • Loading branch information
PaulRC-ioet committed Jan 14, 2021
commit 68844a449c60c14267f7cc1b32964f98277efcf0
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ describe('UsersListComponent', () => {
const actionSub: ActionsSubject = new ActionsSubject();

const state: UserState = {
data: [{ name: 'name', email: 'email', role: 'role', id: 'id', tenant_id: 'tenant id', deleted: 'delete' }],
data: [
{
name: 'name',
email: 'email',
role: null,
roles: ['admin', 'test'],
id: 'id',
tenant_id: 'tenant id',
deleted: 'delete',
},
],
isLoading: false,
message: '',
};
Expand Down Expand Up @@ -59,6 +69,21 @@ describe('UsersListComponent', () => {
expect(component.users).toEqual(state.data);
});

it('on success load users, the data of role should be an array and role null', () => {
const actionSubject = TestBed.inject(ActionsSubject) as ActionsSubject;
const action = {
type: UserActionTypes.LOAD_USERS_SUCCESS,
payload: state.data,
};

actionSubject.next(action);

component.users.map((user) => {
expect(user.role).toEqual(null);
expect(user.roles).toEqual(['admin', 'test']);
});
});

it('on success load users, the datatable should be reloaded', async () => {
const actionSubject = TestBed.inject(ActionsSubject);
const action = {
Expand Down