From 7ade2c21610b7b1f8ae36956172478f14e2e07b0 Mon Sep 17 00:00:00 2001 From: tangoyankee Date: Mon, 19 Aug 2024 16:20:41 -0400 Subject: [PATCH] cleanup tests --- app/components/AdminDropdown/BoroughDropdown.test.tsx | 7 +++++-- app/components/AdminDropdown/index.test.tsx | 4 ++-- app/components/MobilePanelResizeBar.test.tsx | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/components/AdminDropdown/BoroughDropdown.test.tsx b/app/components/AdminDropdown/BoroughDropdown.test.tsx index a0e492a..1695b0e 100644 --- a/app/components/AdminDropdown/BoroughDropdown.test.tsx +++ b/app/components/AdminDropdown/BoroughDropdown.test.tsx @@ -2,6 +2,7 @@ import { Borough, createBorough } from "~/gen"; import { BoroughDropdown } from "./BoroughDropdown"; import { render, screen } from "@testing-library/react"; import { userEvent } from "@testing-library/user-event"; +import { act } from "react"; describe("BoroughDropdown", () => { let boroughs: Array = []; @@ -33,7 +34,7 @@ describe("BoroughDropdown", () => { />, ); - await userEvent.selectOptions(screen.getByRole("combobox"), ""); + await act(() => userEvent.selectOptions(screen.getByRole("combobox"), "")); expect(updateSearchParams).toHaveBeenCalledWith({ districtType: "cd", }); @@ -49,7 +50,9 @@ describe("BoroughDropdown", () => { />, ); - await userEvent.selectOptions(screen.getByRole("combobox"), firstBoroughId); + await act(() => + userEvent.selectOptions(screen.getByRole("combobox"), firstBoroughId), + ); expect(updateSearchParams).toHaveBeenCalledWith({ districtType: "cd", boroughId: firstBoroughId, diff --git a/app/components/AdminDropdown/index.test.tsx b/app/components/AdminDropdown/index.test.tsx index f410b9e..969e2c9 100644 --- a/app/components/AdminDropdown/index.test.tsx +++ b/app/components/AdminDropdown/index.test.tsx @@ -51,7 +51,7 @@ describe("AdminDropdown", () => { expect(testSelect?.selected).toBe(true); }); - it("should call function when form label is clicked", () => { + it("should call function when form label is clicked", async () => { const onFormLabelClick = vi.fn(); render( @@ -65,7 +65,7 @@ describe("AdminDropdown", () => { , ); - fireEvent.click(screen.getByText("Test Boundary")); + await act(() => fireEvent.click(screen.getByText("Test Boundary"))); expect(onFormLabelClick).toHaveBeenCalled(); }); diff --git a/app/components/MobilePanelResizeBar.test.tsx b/app/components/MobilePanelResizeBar.test.tsx index b12f138..35f8179 100644 --- a/app/components/MobilePanelResizeBar.test.tsx +++ b/app/components/MobilePanelResizeBar.test.tsx @@ -1,7 +1,7 @@ import { fireEvent, render, screen } from "@testing-library/react"; import { MobilePanelResizeBar } from "./MobilePanelResizeBar"; -describe("MobilePanelSizeControl", () => { +describe("MobilePanelResizeBar", () => { it("should have be clickable to expand", async () => { const isExpanded = false; const isExpandedToggle = vi.fn();