Skip to content

Commit

Permalink
test capital commitments table
Browse files Browse the repository at this point in the history
  • Loading branch information
TangoYankee committed Aug 7, 2024
1 parent 5d08853 commit 5010016
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import {
CapitalCommitment,
CapitalCommitmentType,
createCapitalCommitment,
createCapitalCommitmentType,
} from "~/gen";
import { CapitalCommitmentsTable } from "./CapitalCommitmentsTable";
import { render, screen } from "@testing-library/react";

describe("CapitalCommitmentsTable", () => {
let capitalCommitments: Array<CapitalCommitment> = [];
let capitalCommitmentTypes: Array<CapitalCommitmentType> = [];
beforeAll(() => {
capitalCommitments = Array.from(Array(1), () =>
createCapitalCommitment({
type: "CONS",
plannedDate: `${new Date("April 2024")}`,
totalValue: 1e6,
}),
);
capitalCommitmentTypes = Array.from(Array(1), () =>
createCapitalCommitmentType({
code: "CONS",
description: "CONSTRUCTION",
}),
);
});

it("should render the table header", () => {
render(
<CapitalCommitmentsTable
capitalCommitments={capitalCommitments}
capitalCommitmentTypes={capitalCommitmentTypes}
/>,
);

expect(screen.getByText(/Date/)).toBeVisible();
expect(screen.getByText(/Description/)).toBeVisible();
expect(screen.getByText(/Commitment/)).toBeVisible();
});

it("should render the month and year of the commitment", () => {
render(
<CapitalCommitmentsTable
capitalCommitments={capitalCommitments}
capitalCommitmentTypes={capitalCommitmentTypes}
/>,
);
expect(screen.getByText(/Apr 2024/)).toBeVisible();
});

it("should render the description of the commitment type", () => {
render(
<CapitalCommitmentsTable
capitalCommitments={capitalCommitments}
capitalCommitmentTypes={capitalCommitmentTypes}
/>,
);
expect(screen.getByText(/CONSTRUCTION/)).toBeVisible();
});

it("should render the value of the commitment", () => {
render(
<CapitalCommitmentsTable
capitalCommitments={capitalCommitments}
capitalCommitmentTypes={capitalCommitmentTypes}
/>,
);

expect(screen.getByText(/\$1.00M/)).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
} from "../types/FindCapitalProjectGeoJsonByManagingCodeCapitalProjectId";

/**
* @summary 🚧 Find a single capital project as a geojson feature
* @summary Find a single capital project as a geojson feature
* @link /capital-projects/:managingCode/:capitalProjectId/geojson
*/
export async function findCapitalProjectGeoJsonByManagingCodeCapitalProjectId(
Expand Down

0 comments on commit 5010016

Please sign in to comment.