@@ -106,16 +106,25 @@ describe('UserEffects', () => {
106
106
} ) ;
107
107
} ) ;
108
108
109
+ < < < << << HEAD
109
110
it ( 'action type is ADD_USER_TO_GROUP_SUCCESS when service is executed sucessfully' , async ( ) => {
110
111
const userId = 'userId' ;
111
112
const groupName = 'groupName' ;
112
113
actions$ = of ( {
113
114
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
114
122
userId ,
115
123
groupName,
116
124
} ) ;
117
125
118
126
spyOn ( toastrService , 'success' ) ;
127
+ < < < << << HEAD
119
128
spyOn ( service , 'addUserToGroup' ) . and . returnValue ( of ( user ) ) ;
120
129
121
130
effects . addUserToGroup$ . subscribe ( ( action ) => {
@@ -129,11 +138,27 @@ describe('UserEffects', () => {
129
138
const groupName = 'groupName' ;
130
139
actions$ = of ( {
131
140
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
132
156
userId ,
133
157
groupName,
134
158
} ) ;
135
159
136
160
spyOn ( toastrService , 'error' ) ;
161
+ < < < << << HEAD
137
162
spyOn ( service , 'addUserToGroup' ) . and . returnValue ( throwError ( { error : { message : 'error' } } ) ) ;
138
163
139
164
effects . addUserToGroup$ . subscribe ( ( action ) => {
@@ -147,11 +172,27 @@ describe('UserEffects', () => {
147
172
const groupName = 'groupName' ;
148
173
actions$ = of ( {
149
174
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
150
190
userId ,
151
191
groupName,
152
192
} ) ;
153
193
154
194
spyOn ( toastrService , 'success' ) ;
195
+ < < < << << HEAD
155
196
spyOn ( service , 'removeUserFromGroup' ) . and . returnValue ( of ( user ) ) ;
156
197
157
198
effects . removeUserFromGroup$ . subscribe ( ( action ) => {
@@ -165,16 +206,39 @@ describe('UserEffects', () => {
165
206
const groupName = 'groupName' ;
166
207
actions$ = of ( {
167
208
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
168
224
userId ,
169
225
groupName,
170
226
} ) ;
171
227
172
228
spyOn ( toastrService , 'error' ) ;
229
+ < < < << << HEAD
173
230
spyOn ( service , 'removeUserFromGroup' ) . and . returnValue ( throwError ( { error : { message : 'error' } } ) ) ;
174
231
175
232
effects . removeUserFromGroup$ . subscribe ( ( action ) => {
176
233
expect ( toastrService . error ) . toHaveBeenCalled ( ) ;
177
234
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
178
242
} ) ;
179
243
} ) ;
180
244
} ) ;
0 commit comments