aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/forms/fieldset.test.tsx
blob: f397bcdbbf8ce64a5612f4f98d30c04eda1eb5b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { render, screen } from '../../../../tests/utils';
import { Fieldset } from './fieldset';
import { body, legend, Tooltip } from './fieldset.fixture';

describe('Fieldset', () => {
  // Cannot use toBeInTheDocument because of body is not an HTMLElement.

  it('renders a legend and a body', () => {
    render(<Fieldset legend={legend}>{body}</Fieldset>);
    expect(screen.findByRole('group', { name: legend })).toBeTruthy();
    expect(screen.findByText(body)).toBeTruthy();
  });

  it('renders a button to open a tooltip', () => {
    render(
      <Fieldset legend={legend} Tooltip={Tooltip}>
        {body}
      </Fieldset>
    );
    expect(screen.findByRole('button', { name: /Help/i })).toBeTruthy();
  });
});
front icon. */ children: JSX.Element; /** * Which side of the label should be displayed? True for the close icon. */ isActive: boolean; }; export const FlippingLabel: FC<FlippingLabelProps> = ({ children, className = '', isActive, ...props }) => { const wrapperModifier = isActive ? 'wrapper--active' : 'wrapper--inactive'; return ( <Label {...props} className={`${styles.label} ${className}`}> <span className={`${styles.wrapper} ${styles[wrapperModifier]}`}> <span className={styles.front}>{children}</span> <span className={styles.back}> <Icon aria-hidden={true} shape="cross" /> </span> </span> </Label> ); };