import MessageBlock from "$/component/message/MessageBlock";
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";


const messageText = "This is a message block component used for displaying messages to users.";


describe("Message Block", () => {
	it("Renders with default properties", () => {
		render(<MessageBlock>{messageText}</MessageBlock>);

		//Make sure the message div is present
		const messageBlock = screen.getByTestId("mattrixwv-message-block");
		expect(messageBlock).toBeInTheDocument();
		expect(messageBlock).toHaveTextContent(messageText);
		//Check for the default classes
		expect(messageBlock).toHaveClass("px-4", "py-2");
		expect(messageBlock).toHaveClass("border");
		expect(messageBlock).toHaveClass("rounded-lg");
	});
	it("Renders with custom className", () => {
		const customClassName = "custom-message-block-class";

		render(<MessageBlock className={customClassName}>{messageText}</MessageBlock>);

		//Make sure the message div is present
		const messageBlock = screen.getByTestId("mattrixwv-message-block");
		expect(messageBlock).toBeInTheDocument();
		expect(messageBlock).toHaveTextContent(messageText);
		//Check for the custom class
		expect(messageBlock).toHaveClass(customClassName);
	});
	it("Renders with aria-label", () => {
		const ariaLabel = "Message Block Aria Label";

		render(<MessageBlock aria-label={ariaLabel}>{messageText}</MessageBlock>);

		//Make sure the message div is present
		const messageBlock = screen.getByTestId("mattrixwv-message-block");
		expect(messageBlock).toBeInTheDocument();
		expect(messageBlock).toHaveTextContent(messageText);
		//Check for the aria-label attribute
		expect(messageBlock).toHaveAttribute("aria-label", ariaLabel);
	});
	describe("Outline Variants", () => {
		it("Renders with no outline", () => {
			render(<MessageBlock outline="none">{messageText}</MessageBlock>);

			//Make sure the message div is present
			const messageBlock = screen.getByTestId("mattrixwv-message-block");
			expect(messageBlock).toBeInTheDocument();
			expect(messageBlock).toHaveTextContent(messageText);
			//Check for the no outline class
			expect(messageBlock).toHaveClass("border-0");
		});
		it("Renders with small outline", () => {
			render(<MessageBlock outline="sm">{messageText}</MessageBlock>);

			//Make sure the message div is present
			const messageBlock = screen.getByTestId("mattrixwv-message-block");
			expect(messageBlock).toBeInTheDocument();
			expect(messageBlock).toHaveTextContent(messageText);
			//Check for the small outline class
			expect(messageBlock).toHaveClass("border");
		});
		it("Renders with medium outline", () => {
			render(<MessageBlock outline="md">{messageText}</MessageBlock>);

			//Make sure the message div is present
			const messageBlock = screen.getByTestId("mattrixwv-message-block");
			expect(messageBlock).toBeInTheDocument();
			expect(messageBlock).toHaveTextContent(messageText);
			//Check for the medium outline class
			expect(messageBlock).toHaveClass("border-2");
		});
		it("Renders with large outline", () => {
			render(<MessageBlock outline="lg">{messageText}</MessageBlock>);

			//Make sure the message div is present
			const messageBlock = screen.getByTestId("mattrixwv-message-block");
			expect(messageBlock).toBeInTheDocument();
			expect(messageBlock).toHaveTextContent(messageText);
			//Check for the large outline class
			expect(messageBlock).toHaveClass("border-3");
		});
	});
	describe("Rounded Variants", () => {
		it("Renders with no rounding", () => {
			render(<MessageBlock rounded="none">{messageText}</MessageBlock>);

			//Make sure the message div is present
			const messageBlock = screen.getByTestId("mattrixwv-message-block");
			expect(messageBlock).toBeInTheDocument();
			expect(messageBlock).toHaveTextContent(messageText);
			//Check for the no rounding class
			expect(messageBlock).toHaveClass("rounded-none");
		});
		it("Renders with extra small rounding", () => {
			render(<MessageBlock rounded="xs">{messageText}</MessageBlock>);

			//Make sure the message div is present
			const messageBlock = screen.getByTestId("mattrixwv-message-block");
			expect(messageBlock).toBeInTheDocument();
			expect(messageBlock).toHaveTextContent(messageText);
			//Check for the extra small rounding class
			expect(messageBlock).toHaveClass("rounded-xs");
		});
		it("Renders with small rounding", () => {
			render(<MessageBlock rounded="sm">{messageText}</MessageBlock>);

			//Make sure the message div is present
			const messageBlock = screen.getByTestId("mattrixwv-message-block");
			expect(messageBlock).toBeInTheDocument();
			expect(messageBlock).toHaveTextContent(messageText);
			//Check for the small rounding class
			expect(messageBlock).toHaveClass("rounded-sm");
		});
		it("Renders with medium rounding", () => {
			render(<MessageBlock rounded="md">{messageText}</MessageBlock>);

			//Make sure the message div is present
			const messageBlock = screen.getByTestId("mattrixwv-message-block");
			expect(messageBlock).toBeInTheDocument();
			expect(messageBlock).toHaveTextContent(messageText);
			//Check for the medium rounding class
			expect(messageBlock).toHaveClass("rounded-md");
		});
		it("Renders with large rounding", () => {
			render(<MessageBlock rounded="lg">{messageText}</MessageBlock>);

			//Make sure the message div is present
			const messageBlock = screen.getByTestId("mattrixwv-message-block");
			expect(messageBlock).toBeInTheDocument();
			expect(messageBlock).toHaveTextContent(messageText);
			//Check for the large rounding class
			expect(messageBlock).toHaveClass("rounded-lg");
		});
		it("Renders with extra large rounding", () => {
			render(<MessageBlock rounded="xl">{messageText}</MessageBlock>);

			//Make sure the message div is present
			const messageBlock = screen.getByTestId("mattrixwv-message-block");
			expect(messageBlock).toBeInTheDocument();
			expect(messageBlock).toHaveTextContent(messageText);
			//Check for the extra large rounding class
			expect(messageBlock).toHaveClass("rounded-xl");
		});
	});
});
