File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,33 @@ describe("UsersPage", () => {
179
179
} )
180
180
181
181
describe ( "suspend user" , ( ) => {
182
+ describe ( "when it is success" , ( ) => {
183
+ it ( "shows a success message and refresh the page" , async ( ) => {
184
+ render (
185
+ < >
186
+ < UsersPage />
187
+ < GlobalSnackbar />
188
+ </ > ,
189
+ )
190
+
191
+ await suspendUser ( ( ) => {
192
+ jest . spyOn ( API , "suspendUser" ) . mockResolvedValueOnce ( MockUser )
193
+ jest
194
+ . spyOn ( API , "getUsers" )
195
+ . mockImplementationOnce ( ( ) => Promise . resolve ( [ MockUser , MockUser2 ] ) )
196
+ } )
197
+
198
+ // Check if the success message is displayed
199
+ screen . findByText ( usersXServiceLanguage . suspendUserSuccess )
200
+
201
+ // Check if the API was called correctly
202
+ expect ( API . suspendUser ) . toBeCalledTimes ( 1 )
203
+ expect ( API . suspendUser ) . toBeCalledWith ( MockUser . id )
204
+
205
+ // Check if the users list was reload
206
+ await waitFor ( ( ) => expect ( API . getUsers ) . toBeCalledTimes ( 1 ) )
207
+ } )
208
+ } )
182
209
describe ( "when it fails" , ( ) => {
183
210
it ( "shows an error message" , async ( ) => {
184
211
render (
You can’t perform that action at this time.
0 commit comments