consistent use of fakeTimers

This commit is contained in:
Min RK
2024-08-29 14:44:16 +02:00
parent 992bc98ff1
commit 6ccb809a2a
7 changed files with 19 additions and 15 deletions

View File

@@ -45,6 +45,7 @@ beforeEach(() => {
afterEach(() => {
useDispatch.mockClear();
jest.runAllTimers();
});
test("Renders", async () => {
@@ -78,15 +79,15 @@ test("Correctly submits admin", async () => {
await act(async () => {
render(addUserJsx(callbackSpy));
});
let textarea = screen.getByTestId("user-textarea");
let submit = screen.getByTestId("submit");
let check = screen.getByTestId("check");
await userEvent.click(check);
fireEvent.blur(textarea, { target: { value: "foo" } });
await fireEvent.blur(textarea, { target: { value: "foo" } });
await fireEvent.click(check);
await fireEvent.click(submit);
await act(async () => {
await fireEvent.click(submit);
await jest.runAllTimers();
});
expect(callbackSpy).toHaveBeenCalledWith(["foo"], true);