2022-06-15 23:37:15 +02:00
|
|
|
import { render, screen } from "./reactUtils";
|
2021-06-12 22:44:56 +02:00
|
|
|
import CustomError from "@components/CustomError";
|
2021-03-18 18:52:58 +01:00
|
|
|
|
2022-06-15 23:37:15 +02:00
|
|
|
const code = Math.random() * 199 + 400;
|
|
|
|
|
const text = "Testing fake error";
|
2021-03-28 23:17:47 +02:00
|
|
|
|
2021-03-18 18:52:58 +01:00
|
|
|
it("loads the layout correctly", async () => {
|
2021-03-28 23:17:47 +02:00
|
|
|
render(<CustomError statusCode={code} statusText={text} />);
|
2021-03-18 18:52:58 +01:00
|
|
|
|
|
|
|
|
expect(screen.getByRole("link", { name: /skip to content/i })).toBeEnabled();
|
|
|
|
|
expect(await screen.findByRole("img", { name: /logo/i })).toBeVisible();
|
|
|
|
|
expect(screen.getByRole("button", { name: /toggle color mode/i })).toBeEnabled();
|
|
|
|
|
expect(screen.getByRole("link", { name: /github/i })).toBeEnabled();
|
|
|
|
|
expect(screen.getByText(/\xA9/)).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
2021-03-28 23:17:47 +02:00
|
|
|
it("renders the correct status code & text", () => {
|
|
|
|
|
render(<CustomError statusCode={code} statusText={text} />);
|
|
|
|
|
|
2021-03-18 18:52:58 +01:00
|
|
|
expect(screen.getByText(code)).toBeVisible();
|
2021-03-28 23:17:47 +02:00
|
|
|
expect(screen.getByText(text)).toBeVisible();
|
2021-03-18 18:52:58 +01:00
|
|
|
});
|