Fix tests

This commit is contained in:
0x1eef 2024-04-05 15:44:49 -03:00
parent c76c40af05
commit f5d7fc2050
3 changed files with 9 additions and 11 deletions

View file

@ -7,7 +7,8 @@ export function ErrorRenderer({ error }: { error: Error }) {
<div data-testid="error" className="w-full h-48"> <div data-testid="error" className="w-full h-48">
<div className="flex flex-col h-5/6 justify-center w-3/4 m-auto"></div> <div className="flex flex-col h-5/6 justify-center w-3/4 m-auto"></div>
<Footer> <Footer>
<span className="font-bold">{t("error")}</span>: {error.message} <span className="font-bold">{t("error")}</span>:
<span data-testid="error-message">{error.message}</span>
</Footer> </Footer>
</div> </div>
); );

View file

@ -18,7 +18,9 @@ describe("ErrorRenderer.tsx", () => {
}); });
test("an error is rendered", () => { test("an error is rendered", () => {
expect(screen.getByText("Error")).toBeInTheDocument(); const { getByTestId, getByText } = screen;
expect(screen.getByText(error.message)).toBeInTheDocument(); const span = getByTestId("error-message");
expect(getByText("Error")).toBeInTheDocument();
expect(span.textContent).toEqual(error.message);
}); });
}); });

View file

@ -39,14 +39,9 @@ describe("ResponseRenderer.tsx", () => {
expect(screen.getByText(response.ISP)).toBeInTheDocument(); expect(screen.getByText(response.ISP)).toBeInTheDocument();
}); });
test("a city is rendered", () => { test("a location is rendered", () => {
expect(screen.getByText("City")).toBeInTheDocument(); expect(screen.getByText("Location")).toBeInTheDocument();
expect(screen.getByText(response.City)).toBeInTheDocument(); expect(screen.getByText(`${response.City}, ${response.Country}`)).toBeInTheDocument();
});
test("a country is rendered", () => {
expect(screen.getByText("Country")).toBeInTheDocument();
expect(screen.getByText(response.Country)).toBeInTheDocument();
}); });
test("isTorExitNode is rendered as No", () => { test("isTorExitNode is rendered as No", () => {