Skip to content

Commit da54874

Browse files
authoredAug 24, 2022
fixed users test (#3676)
1 parent 57c202d commit da54874

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
 

‎site/src/pages/UsersPage/UsersPage.test.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,33 @@ describe("UsersPage", () => {
179179
})
180180

181181
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+
})
182209
describe("when it fails", () => {
183210
it("shows an error message", async () => {
184211
render(

0 commit comments

Comments
 (0)