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
TT-111 fix: add a new test for user roles
  • Loading branch information
PaulRC-ioet committed Jan 15, 2021
commit 2767e3313504be9dc0245f996b6f9b8d828748c0
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('UsersListComponent', () => {
expect(component.users).toEqual(state.data);
});

it('on success load users, the data of role should be an array and role null', () => {
it('on success load users, the data of roles should be an array and role null', () => {
const actionSubject = TestBed.inject(ActionsSubject) as ActionsSubject;
const action = {
type: UserActionTypes.LOAD_USERS_SUCCESS,
Expand All @@ -84,6 +84,36 @@ describe('UsersListComponent', () => {
});
});

it('on success load users, the data of roles should be null and role a string', () => {
const actionSubject = TestBed.inject(ActionsSubject) as ActionsSubject;
const mockState: UserState = {
data: [
{
name: 'name',
email: 'email',
role: 'admin',
roles: null,
id: 'id',
tenant_id: 'tenant id',
deleted: 'delete',
},
],
isLoading: false,
message: '',
};
const action = {
type: UserActionTypes.LOAD_USERS_SUCCESS,
payload: mockState.data,
};

actionSubject.next(action);

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

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