@@ -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