Skip to content

Commit

Permalink
tests updated
Browse files Browse the repository at this point in the history
  • Loading branch information
mantuok committed Nov 25, 2024
1 parent ea9e2db commit baa99df
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/components/__tests__/card-hazard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,35 @@ jest.mock("../pill.tsx", () => () => (
describe("CardHazard Component", () => {
beforeEach(() => {
Hazards[0] = {
id: 4,
title: "Earthquake",
name: "seismic",
description: "Potential hazard in the area.",
color: "#FF0000",
update: "2 days ago",
};
});

it("renders without crashing", () => {
render(<CardHazard />);
render(<CardHazard hazard={Hazards[0]} />);
expect(screen.getByText("Earthquake")).toBeInTheDocument();
});

it("displays the hazard title and description", () => {
render(<CardHazard />);
render(<CardHazard hazard={Hazards[0]} />);
expect(screen.getByText("Earthquake")).toBeInTheDocument();
expect(
screen.getByText("Potential hazard in the area.")
).toBeInTheDocument();
});

it("displays the hazard's updated time", () => {
render(<CardHazard />);
render(<CardHazard hazard={Hazards[0]} />);
expect(screen.getByText("Updated 2 days ago")).toBeInTheDocument();
});

it("displays the hazard's color in the SVG circle", () => {
render(<CardHazard />);
render(<CardHazard hazard={Hazards[0]} />);
const svgCircle = screen.getByRole("img", { hidden: true });
expect(svgCircle).toHaveAttribute("fill", "#FF0000");
});
Expand Down

0 comments on commit baa99df

Please sign in to comment.