Skip to content

Commit

Permalink
fix(toast): better test
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-rb committed Sep 19, 2024
1 parent 4fba5dc commit 40e95bc
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/core/src/toast/toast.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,8 @@ describe("Toast", () => {
expect(toasts.length).toBe(limit);
});

it("should not render dismissed toasts", async () => {
const limit = 3;
it("should not use dismissed toasts for list", async () => {
const limit = 1;

let closeId: number;

Expand All @@ -527,27 +527,28 @@ describe("Toast", () => {
type="button"
data-testid="trigger"
onClick={() => {
showToast();
closeId = showToast();
}}
>
Show more than limit
Show Toast
</button>
<Toast.Region limit={limit}>
<Toast.List />
<Toast.List data-testid="custom-region" />
</Toast.Region>
</>
));

fireEvent.click(getByTestId("trigger"));

let toasts = getAllByRole("status");
fireEvent.click(getByTestId("dismiss-toast"));

expect(toasts.length).toBe(2);
let toasts =
getByTestId("custom-region").querySelectorAll('[role="status"]');
expect(toasts.length).toBe(0);

fireEvent.click(getByTestId("dismiss-toast"));
fireEvent.click(getByTestId("trigger"));

toasts = getAllByRole("status");
toasts = getByTestId("custom-region").querySelectorAll('[role="status"]');

expect(toasts.length).toBe(1);
});
Expand Down

0 comments on commit 40e95bc

Please sign in to comment.