UNPKG

@octopusdeploy/design-system-components

Version:
39 lines (38 loc) 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("@testing-library/react"); const vitest_1 = require("vitest"); const vitest_axe_1 = require("vitest-axe"); const SectionHeader_1 = require("../SectionHeader"); (0, vitest_1.describe)("SectionHeader", () => { (0, vitest_1.it)("is accessible", async () => { const sectionHeader = renderSectionHeader({ title: "title", description: "description" }); await sectionHeader.shouldBeAccessible(); }); (0, vitest_1.it)("shows title and description when provided", () => { const title = "title"; const description = "description"; const sectionHeader = renderSectionHeader({ title, description }); sectionHeader.shouldShowTitle(title); sectionHeader.shouldShowDescription(description); }); }); function renderSectionHeader({ title, description }) { const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(SectionHeader_1.SectionHeader, { title: title, description: description })); return sectionHeaderInteractions(container); } function sectionHeaderInteractions(container) { return { shouldShowTitle: (title) => { (0, vitest_1.expect)(react_1.screen.getByText(title)).toBeInTheDocument(); }, shouldShowDescription: (description) => { (0, vitest_1.expect)(react_1.screen.getByText(description)).toBeInTheDocument(); }, shouldBeAccessible: async () => { const results = await (0, vitest_axe_1.axe)(container); (0, vitest_1.expect)(results).toHaveNoViolations(); }, }; }