import * as React from "react";

import { ThemeProvider } from "styled-components";
import { render, cleanup, screen } from "@testing-library/react";
import { parseTheme } from "@ax/helpers";
import "@testing-library/jest-dom";

import ErrorToast, { IProps } from "@ax/components/ErrorToast";
import globalTheme from "@ax/themes/theme.json";

afterEach(cleanup);

describe("ErrorToast component rendering", () => {
	it("should render the component", () => {
		const defaultProps: IProps = {
			size: "m",
		};

		render(
			<ThemeProvider theme={parseTheme(globalTheme)}>
				<ErrorToast {...defaultProps} />
			</ThemeProvider>,
		);

		const errorWrapper = screen.getByTestId("error-wrapper");
		expect(errorWrapper).toBeTruthy();
	});

	it("should render the component with no size", () => {
		render(
			<ThemeProvider theme={parseTheme(globalTheme)}>
				<ErrorToast />
			</ThemeProvider>,
		);

		const errorWrapper = screen.getByTestId("error-wrapper");
		expect(errorWrapper).toBeTruthy();
	});

	it("should render the component with a wrong size value", () => {
		const defaultProps: IProps = {
			// biome-ignore lint/suspicious/noTsIgnore: TODO: fix this
			// @ts-ignore
			size: 100,
		};

		render(
			<ThemeProvider theme={parseTheme(globalTheme)}>
				<ErrorToast {...defaultProps} />
			</ThemeProvider>,
		);

		const errorWrapper = screen.getByTestId("error-wrapper");
		expect(errorWrapper).toBeTruthy();
	});
});
