wimi/test/ErrorRenderer.test.tsx

25 lines
714 B
TypeScript
Raw Normal View History

2023-09-28 23:10:15 +02:00
import React from "react";
2023-09-29 20:25:24 +02:00
import '@testing-library/jest-dom';
2023-09-28 23:10:15 +02:00
import { render, screen } from "@testing-library/react";
import { ErrorRenderer } from "~/components/ErrorRenderer";
import { getMessage } from "./mocks/chrome.i18n";
describe("ErrorRenderer.tsx", () => {
const error = new Error("This is an example error message");
beforeEach(() => {
2023-09-29 20:25:24 +02:00
const chrome: any = { i18n: { getMessage } };
2023-09-28 23:10:15 +02:00
global.chrome = chrome;
render(<ErrorRenderer error={error}/>);
});
afterEach(() => {
global.chrome = undefined;
});
test("an error is rendered", () => {
expect(screen.getByText("Error")).toBeInTheDocument();
expect(screen.getByText(error.message)).toBeInTheDocument();
});
});