Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
acouch committed Jul 5, 2024
1 parent b4954ae commit abd7ca8
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class APISearchFetcher extends SearchFetcher {
): Promise<SearchAPIResponse> {
try {
// Keep commented in case we need to simulate a delay to test loaders
await new Promise((resolve) => setTimeout(resolve, 3250));
// await new Promise((resolve) => setTimeout(resolve, 3250));

const response: SearchAPIResponse =
await this.searchApi.searchOpportunities(searchInputs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ describe("SearchFilterAccordion", () => {
expect(clearAllButton).toBeInTheDocument();
expect(clearAllButton).toBeDisabled();

const cooperativeAgreementCheckbox = screen.getByLabelText(
"Cooperative Agreement",
);

const updatedQuery = new Set("");
updatedQuery.add("Cooperative Agreement");
// after clicking one of the boxes, the page should rerender
Expand Down Expand Up @@ -155,11 +151,6 @@ describe("SearchFilterAccordion", () => {
/>,
);

const cooperativeAgreementCheckbox = screen.getByLabelText(
"Cooperative Agreement",
);
const grantCheckbox = screen.getByLabelText("Grant");

// Verify the count updates to 2
const countSpan = screen.getByText("2", {
selector: ".usa-tag.usa-tag--big.radius-pill.margin-left-1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import React from "react";
import SearchFilterCheckbox from "src/components/search/SearchFilterAccordion/SearchFilterCheckbox";
import { axe } from "jest-axe";

const mockIncrement = jest.fn();
const mockUpdateCheckedOption = jest.fn();
const option = {
id: "test-option",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "@testing-library/jest-dom";

import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { fireEvent, render, screen } from "@testing-library/react";

import React from "react";
import SearchFilterSection from "src/components/search/SearchFilterAccordion/SearchFilterSection/SearchFilterSection";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("SearchOpportunityStatus", () => {
expect(screen.getByText("Archived")).toBeEnabled();
});

it("checking a checkbox calls updateQueryParams and requestSubmit", async () => {
it("checking a checkbox calls updateQueryParams and requestSubmit", () => {
const query = new Set("");
query.add("test");
const combined = new Set("");
Expand Down
3 changes: 2 additions & 1 deletion frontend/tests/components/search/SearchPagination.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable jest/no-commented-out-tests */
import "@testing-library/jest-dom/extend-expect";
import { axe } from "jest-axe";
import { fireEvent, render, screen } from "@testing-library/react";
import { render } from "@testing-library/react";
import React from "react";
import SearchPagination from "src/components/search/SearchPagination";

Expand Down
6 changes: 3 additions & 3 deletions frontend/tests/components/search/SearchSortBy.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ describe("SearchSortBy", () => {
});

it("updates sort option and submits the form on change", () => {
const container = render(
render(
<QueryProvider>
<SearchSortBy totalResults={"10"} queryTerm="test" sortby="" />
</QueryProvider>,
);

fireEvent.change(container.getByRole("combobox"), {
fireEvent.change(screen.getByRole("combobox"), {
target: { value: "opportunityTitleDesc" },
});

expect(
container.getByText("Opportunity Title (Z to A)"),
screen.getByText("Opportunity Title (Z to A)"),
).toBeInTheDocument();
});
});
3 changes: 1 addition & 2 deletions frontend/tests/hooks/useSearchParamUpdater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import { renderHook, waitFor } from "@testing-library/react";
import { useSearchParamUpdater } from "src/hooks/useSearchParamUpdater";


let mockSearchParams = new URLSearchParams();
const mockSearchParams = new URLSearchParams();
const routerPush = jest.fn(() => Promise.resolve(true));
jest.mock("next/navigation", () => ({
usePathname: jest.fn(() => "/test") as jest.Mock<string>,
Expand Down

0 comments on commit abd7ca8

Please sign in to comment.