UNPKG

@redocly/theme

Version:

Shared UI components lib

33 lines 1.75 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.testIconComponent = testIconComponent; const react_1 = __importDefault(require("react")); const react_2 = require("@testing-library/react"); require("@testing-library/jest-dom"); function testIconComponent(IconComponent, componentName) { const dataName = `icons/${componentName}/${componentName}`; return { rendersCorrectlyWithDefaultProps: () => { const { container } = (0, react_2.render)(react_1.default.createElement(IconComponent, null)); const svgElement = container.querySelector('svg'); expect(svgElement).toBeInTheDocument(); expect(container.firstChild).toHaveStyle('height: 16px; width: 16px;'); }, appliesCustomSizeAndColor: () => { const { container } = (0, react_2.render)(react_1.default.createElement(IconComponent, { size: "24px", color: "--color-primary" })); const svgElement = container.querySelector('svg'); expect(svgElement).toBeInTheDocument(); expect(container.firstChild).toHaveStyle('height: 24px; width: 24px;'); const pathElement = container.querySelector('path'); expect(pathElement).toHaveStyle('fill: var(--color-primary);'); }, hasCorrectDataComponentName: () => { const { container } = (0, react_2.render)(react_1.default.createElement(IconComponent, null)); expect(container.firstChild).toHaveAttribute('data-component-name', dataName); }, }; } //# sourceMappingURL=IconTestUtils.js.map