Skip to content

Commit 2767e33

Browse files
committed
TT-111 fix: add a new test for user roles
1 parent 68844a4 commit 2767e33

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe('UsersListComponent', () => {
6969
expect(component.users).toEqual(state.data);
7070
});
7171

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

87+
it('on success load users, the data of roles should be null and role a string', () => {
88+
const actionSubject = TestBed.inject(ActionsSubject) as ActionsSubject;
89+
const mockState: UserState = {
90+
data: [
91+
{
92+
name: 'name',
93+
email: 'email',
94+
role: 'admin',
95+
roles: null,
96+
id: 'id',
97+
tenant_id: 'tenant id',
98+
deleted: 'delete',
99+
},
100+
],
101+
isLoading: false,
102+
message: '',
103+
};
104+
const action = {
105+
type: UserActionTypes.LOAD_USERS_SUCCESS,
106+
payload: mockState.data,
107+
};
108+
109+
actionSubject.next(action);
110+
111+
component.users.map((user) => {
112+
expect(user.role).toEqual('admin');
113+
expect(user.roles).toEqual(null);
114+
});
115+
});
116+
87117
it('on success load users, the datatable should be reloaded', async () => {
88118
const actionSubject = TestBed.inject(ActionsSubject);
89119
const action = {

0 commit comments

Comments
 (0)