aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/components/BorderedContainerWithCaption.test.tsx
blob: 621dcb3dcb070637f6c5139138e35f1262be6a10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
 * @vitest-environment jsdom
 */
import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, test } from "vitest";
import BorderedContainerWithCaption from "./BorderedContainerWithCaption";

afterEach(() => {
	cleanup();
});

describe("BorderedContainerWithCaption", () => {
	test("renders caption as heading", () => {
		render(
			<BorderedContainerWithCaption caption="Test Caption">
				Content
			</BorderedContainerWithCaption>,
		);
		expect(screen.getByText("Test Caption")).toBeDefined();
		expect(screen.getByText("Test Caption").tagName).toBe("H2");
	});

	test("renders children", () => {
		render(
			<BorderedContainerWithCaption caption="Title">
				Child Content
			</BorderedContainerWithCaption>,
		);
		expect(screen.getByText("Child Content")).toBeDefined();
	});

	test("wraps in bordered container with blue border", () => {
		render(
			<BorderedContainerWithCaption caption="Title">
				Content
			</BorderedContainerWithCaption>,
		);
		const container = screen.getByText("Content").closest(".border-2");
		expect(container).not.toBeNull();
	});
});