Skip to content

Commit

Permalink
Add assertion for notification message will disappear
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperbirch1 committed Oct 27, 2023
1 parent c728ead commit 0df507e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/tests/unit/notification-message.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe("useNotification hook", () => {

it("Does shows a message if button is clicked", async () => {
vi.spyOn(window, "scrollTo");
vi.spyOn(window, "setTimeout");

const { getByTitle } = render(
<ComponentWithNotificationMessage
Expand All @@ -66,6 +67,8 @@ describe("useNotification hook", () => {

// We expect that the hook has scrolled to the top of the page.
expect(window.scrollTo).toHaveBeenCalledWith(0, 0);
// And the message is gone after 5 seconds.
expect(window.setTimeout).toHaveBeenCalledTimes(1);
// And shows us a message.
expect(wrapper).toMatchInlineSnapshot(`
<div
Expand Down

0 comments on commit 0df507e

Please sign in to comment.