UNPKG

@octopusdeploy/design-system-components

Version:
43 lines (42 loc) 1.95 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 CounterBadge_1 = require("../CounterBadge"); (0, vitest_1.describe)("CounterBadge", () => { (0, vitest_1.describe)("accessibility", () => { (0, vitest_1.test)("is accessible with solid type", async () => { const badge = renderCounterBadge({ type: "solid", label: "5" }); await badge.shouldBeAccessible(); }); (0, vitest_1.test)("is accessible with outlined type", async () => { const badge = renderCounterBadge({ type: "outlined", label: "10" }); await badge.shouldBeAccessible(); }); }); (0, vitest_1.describe)("rendering", () => { (0, vitest_1.test)("renders the label text", () => { const badge = renderCounterBadge({ type: "solid", label: "5" }); badge.shouldShowLabel("5"); }); }); }); function renderCounterBadge({ type, label }) { const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(TestDesignSystemProvider_1.TestDesignSystemProvider, { children: (0, jsx_runtime_1.jsx)(CounterBadge_1.CounterBadge, { type: type, label: label }) })); return getCounterBadgeInteractions(container); } function getCounterBadgeInteractions(container) { return { shouldShowLabel: (label) => { testing_library_1.domQueries.getText(label).assertIsInTheDocument(); }, shouldBeAccessible: async () => { const results = await (0, vitest_axe_1.axe)(container); (0, vitest_1.expect)(results).toHaveNoViolations(); }, }; }