UNPKG

@navinc/base-react-components

Version:
26 lines 1.23 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { describe, expect, it } from 'vitest'; import { screen } from '@testing-library/react'; import { Label } from './label.js'; import { testComponentRef, testComponentCommonStandards } from '@navinc/test-helpers'; import { renderWithContext } from '../../tests/with-app-context.js'; const renderComponent = (props) => (_jsx(Label, Object.assign({}, props, { children: _jsx("input", {}) }))); describe('<HelperText />', () => { testComponentRef(Label); testComponentCommonStandards(Label); it('renders empty div with no props to preserve spacing', () => { renderWithContext(_jsx(Label, {})); expect(screen.getByTestId('label')).toBeEmptyDOMElement(); }); it('renders label text', () => { const label = 'Take this one'; renderWithContext(renderComponent({ label })); expect(screen.getByLabelText(label)); }); it('renders label with "optional" indicator text', () => { const label = 'Take this one'; renderWithContext(renderComponent({ label, optional: true })); expect(screen.getByTestId('label')).toHaveTextContent(`${label} optional`); }); }); //# sourceMappingURL=label.spec.js.map