Skip to content

Commit 68844a4

Browse files
committed
TT-111 fix: add a test to check new model of users
1 parent 20abdbf commit 68844a4

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/app/modules/users/components/users-list/users-list.component.spec.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ describe('UsersListComponent', () => {
1414
const actionSub: ActionsSubject = new ActionsSubject();
1515

1616
const state: UserState = {
17-
data: [{ name: 'name', email: 'email', role: 'role', id: 'id', tenant_id: 'tenant id', deleted: 'delete' }],
17+
data: [
18+
{
19+
name: 'name',
20+
email: 'email',
21+
role: null,
22+
roles: ['admin', 'test'],
23+
id: 'id',
24+
tenant_id: 'tenant id',
25+
deleted: 'delete',
26+
},
27+
],
1828
isLoading: false,
1929
message: '',
2030
};
@@ -59,6 +69,21 @@ describe('UsersListComponent', () => {
5969
expect(component.users).toEqual(state.data);
6070
});
6171

72+
it('on success load users, the data of role should be an array and role null', () => {
73+
const actionSubject = TestBed.inject(ActionsSubject) as ActionsSubject;
74+
const action = {
75+
type: UserActionTypes.LOAD_USERS_SUCCESS,
76+
payload: state.data,
77+
};
78+
79+
actionSubject.next(action);
80+
81+
component.users.map((user) => {
82+
expect(user.role).toEqual(null);
83+
expect(user.roles).toEqual(['admin', 'test']);
84+
});
85+
});
86+
6287
it('on success load users, the datatable should be reloaded', async () => {
6388
const actionSubject = TestBed.inject(ActionsSubject);
6489
const action = {

0 commit comments

Comments
 (0)