Skip to content

Commit

Permalink
test: remove act in favour of async timers
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Makowski <me+git@petermakowski.io>
  • Loading branch information
petermakowski committed May 14, 2024
1 parent 407add1 commit d037a49
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/components/ActionButton/ActionButton.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from "react";
import React, { act } from "react";
import { render, screen } from "@testing-library/react";

import ActionButton, {
Label,
LOADER_MIN_DURATION,
SUCCESS_DURATION,
} from "./ActionButton";
import { act } from "react-dom/test-utils";

describe("ActionButton", () => {
jest.useFakeTimers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
useNotify,
} from "./NotificationProvider";
import Button from "../Button";
import { act } from "react-dom/test-utils";

describe("NotificationProvider", () => {
it("stores and renders notifications", async () => {
Expand Down Expand Up @@ -54,7 +53,7 @@ describe("NotificationProvider", () => {
);

const clickBtn = async (testId: string) =>
await act(async () => await userEvent.click(screen.getByTestId(testId)));
await userEvent.click(screen.getByTestId(testId));

expect(screen.getByTestId("notification-consumer")).toBeEmptyDOMElement();

Expand Down

0 comments on commit d037a49

Please sign in to comment.