UNPKG

@octopusdeploy/design-system-components

Version:
50 lines (49 loc) 2.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const testing_library_1 = require("@octopusdeploy/testing-library"); const react_1 = require("@testing-library/react"); const vitest_1 = require("vitest"); const vitest_axe_1 = require("vitest-axe"); const TestDesignSystemProvider_1 = require("../../TestDesignSystemProvider"); const QuietCallout_1 = require("../QuietCallout"); const quietCalloutTypes = ["info", "success", "warning", "danger", "feature", "upsell"]; (0, vitest_1.describe)("QuietCallout", () => { (0, vitest_1.it)("is accessible with title and body", async () => { const callout = renderQuietCallout({ type: "info", title: "Title", children: "Body content", }); await callout.shouldBeAccessible(); }); vitest_1.it.each(quietCalloutTypes)("renders %s type callout with title and body", (type) => { const title = `${type} callout title`; const body = `${type} callout body`; const callout = renderQuietCallout({ type, title, children: body, }); callout.shouldShowTitle(title); callout.shouldShowBody(body); }); }); function renderQuietCallout(props) { const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(TestDesignSystemProvider_1.TestDesignSystemProvider, { children: (0, jsx_runtime_1.jsx)(QuietCallout_1.QuietCallout, { ...props }) })); return quietCalloutInteractions(container); } function quietCalloutInteractions(container) { return { shouldShowTitle: (title) => { testing_library_1.domQueries.getText(title, { containerElement: container }).assertIsInTheDocument(); }, shouldShowBody: (body) => { testing_library_1.domQueries.getText(body, { containerElement: container }).assertIsInTheDocument(); }, shouldBeAccessible: async () => { const results = await (0, vitest_axe_1.axe)(container); (0, vitest_1.expect)(results).toHaveNoViolations(); }, }; }