@octopusdeploy/design-system-components
Version:
The design systems component library.
52 lines (51 loc) • 2.04 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
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 DeprecatedRadioButton_1 = __importDefault(require("../DeprecatedRadioButton"));
(0, vitest_1.describe)("DeprecatedRadioButton", () => {
(0, vitest_1.test)("is in the document", () => {
const radioButton = renderRadioButton({});
radioButton.assertIsInTheDocument();
});
(0, vitest_1.test)("can be enabled", () => {
const radioButton = renderRadioButton({ disabled: false });
radioButton.assertIsEnabled();
});
(0, vitest_1.test)("can be disabled", () => {
const radioButton = renderRadioButton({ disabled: true });
radioButton.assertIsDisabled();
});
(0, vitest_1.test)("can be auto focused", () => {
const radioButton = renderRadioButton({ autoFocus: true });
radioButton.assertHasFocus();
});
});
const label = "label text";
function renderRadioButton({ disabled, autoFocus }) {
(0, react_1.render)((0, jsx_runtime_1.jsx)(DeprecatedRadioButton_1.default, { label: label, value: "value", disabled: disabled, autoFocus: autoFocus }));
return getRadioButtonInteractions();
}
function getRadioButtonInteractions() {
const radioButton = testing_library_1.domQueries.getRadioButton(label);
const interactions = {
assertIsInTheDocument: () => {
radioButton.assertIsInTheDocument();
},
assertIsDisabled: () => {
radioButton.assertIsDisabled();
},
assertIsEnabled: () => {
radioButton.assertIsEnabled();
},
assertHasFocus: () => {
radioButton.assertHasFocus();
},
};
return interactions;
}