@@ -106,16 +106,25 @@ describe('UserEffects', () => {
106106 } ) ;
107107 } ) ;
108108
109+ < < < << << HEAD
109110 it ( 'action type is ADD_USER_TO_GROUP_SUCCESS when service is executed sucessfully' , async ( ) => {
110111 const userId = 'userId' ;
111112 const groupName = 'groupName' ;
112113 actions$ = of ( {
113114 type : UserActionTypes . ADD_USER_TO_GROUP ,
115+ = === ===
116+ it ( 'action type is ADD_GROUP_TO_USER_SUCCESS when service is executed sucessfully' , async ( ) => {
117+ const userId = 'userId' ;
118+ const groupName = 'groupName' ;
119+ actions$ = of ( {
120+ type : UserActionTypes . ADD_GROUP_TO_USER ,
121+ > >>> >>> feat : TT - 188 add ngrx flow & test
114122 userId ,
115123 groupName,
116124 } ) ;
117125
118126 spyOn ( toastrService , 'success' ) ;
127+ < < < << << HEAD
119128 spyOn ( service , 'addUserToGroup' ) . and . returnValue ( of ( user ) ) ;
120129
121130 effects . addUserToGroup$ . subscribe ( ( action ) => {
@@ -129,11 +138,27 @@ describe('UserEffects', () => {
129138 const groupName = 'groupName' ;
130139 actions$ = of ( {
131140 type : UserActionTypes . ADD_USER_TO_GROUP ,
141+ = === ===
142+ spyOn ( service , 'addGroupToUser' ) . and . returnValue ( of ( user ) ) ;
143+
144+ effects . addGroupToUser$ . subscribe ( ( action ) => {
145+ expect ( toastrService . success ) . toHaveBeenCalledWith ( 'Add group to a user success' ) ;
146+ expect ( action . type ) . toEqual ( UserActionTypes . ADD_GROUP_TO_USER_SUCCESS ) ;
147+ } ) ;
148+ } ) ;
149+
150+ it ( 'action type is ADD_GROUP_TO_USER_FAIL when service is executed and fail' , async ( ) => {
151+ const userId = 'userId' ;
152+ const groupName = 'groupName' ;
153+ actions$ = of ( {
154+ type : UserActionTypes . ADD_GROUP_TO_USER ,
155+ > >>> >>> feat : TT - 188 add ngrx flow & test
132156 userId ,
133157 groupName,
134158 } ) ;
135159
136160 spyOn ( toastrService , 'error' ) ;
161+ < < < << << HEAD
137162 spyOn ( service , 'addUserToGroup' ) . and . returnValue ( throwError ( { error : { message : 'error' } } ) ) ;
138163
139164 effects . addUserToGroup$ . subscribe ( ( action ) => {
@@ -147,11 +172,27 @@ describe('UserEffects', () => {
147172 const groupName = 'groupName' ;
148173 actions$ = of ( {
149174 type : UserActionTypes . REMOVE_USER_FROM_GROUP ,
175+ = === ===
176+ spyOn ( service , 'addGroupToUser' ) . and . returnValue ( throwError ( { error : { message : 'error' } } ) ) ;
177+
178+ effects . addGroupToUser$ . subscribe ( ( action ) => {
179+ expect ( toastrService . error ) . toHaveBeenCalled ( ) ;
180+ expect ( action . type ) . toEqual ( UserActionTypes . ADD_GROUP_TO_USER_FAIL ) ;
181+ } ) ;
182+ } ) ;
183+
184+ it ( 'action type is REMOVE_GROUP_TO_USER_SUCCESS when service is executed succesfully' , async ( ) => {
185+ const userId = 'userId' ;
186+ const groupName = 'groupName' ;
187+ actions$ = of ( {
188+ type : UserActionTypes . REMOVE_GROUP_TO_USER ,
189+ > >>> >>> feat : TT - 188 add ngrx flow & test
150190 userId ,
151191 groupName,
152192 } ) ;
153193
154194 spyOn ( toastrService , 'success' ) ;
195+ < < < << << HEAD
155196 spyOn ( service , 'removeUserFromGroup' ) . and . returnValue ( of ( user ) ) ;
156197
157198 effects . removeUserFromGroup$ . subscribe ( ( action ) => {
@@ -165,16 +206,39 @@ describe('UserEffects', () => {
165206 const groupName = 'groupName' ;
166207 actions$ = of ( {
167208 type : UserActionTypes . REMOVE_USER_FROM_GROUP ,
209+ = === ===
210+ spyOn ( service , 'removeGroupToUser' ) . and . returnValue ( of ( user ) ) ;
211+
212+ effects . removeGroupToUser$ . subscribe ( ( action ) => {
213+ expect ( toastrService . success ) . toHaveBeenCalledWith ( 'Remove group to a user success' ) ;
214+ expect ( action . type ) . toEqual ( UserActionTypes . REMOVE_GROUP_TO_USER_SUCCESS ) ;
215+ } ) ;
216+ } ) ;
217+
218+ it ( 'action type is REMOVE_GROUP_TO_USER_FAIL when service is executed succesfully' , async ( ) => {
219+ const userId = 'userId' ;
220+ const groupName = 'groupName' ;
221+ actions$ = of ( {
222+ type : UserActionTypes . REMOVE_GROUP_TO_USER ,
223+ > >>> >>> feat : TT - 188 add ngrx flow & test
168224 userId ,
169225 groupName,
170226 } ) ;
171227
172228 spyOn ( toastrService , 'error' ) ;
229+ < < < << << HEAD
173230 spyOn ( service , 'removeUserFromGroup' ) . and . returnValue ( throwError ( { error : { message : 'error' } } ) ) ;
174231
175232 effects . removeUserFromGroup$ . subscribe ( ( action ) => {
176233 expect ( toastrService . error ) . toHaveBeenCalled ( ) ;
177234 expect ( action . type ) . toEqual ( UserActionTypes . REMOVE_USER_FROM_GROUP_FAIL ) ;
235+ = === ===
236+ spyOn ( service , 'removeGroupToUser' ) . and . returnValue ( throwError ( { error : { message : 'error' } } ) ) ;
237+
238+ effects . removeGroupToUser$ . subscribe ( ( action ) => {
239+ expect ( toastrService . error ) . toHaveBeenCalled ( ) ;
240+ expect ( action . type ) . toEqual ( UserActionTypes . REMOVE_GROUP_TO_USER_FAIL ) ;
241+ > >>> >>> feat: TT - 188 add ngrx flow & test
178242 } ) ;
179243 } ) ;
180244} ) ;
0 commit comments