fleet/frontend/components/forms/fields/Radio/Radio.tests.tsx
Gabe Hernandez be77b0de59 add tests for new manage users UI and improve checkbox accessibility (#536)
* e2e test for manage user page, and updating styles for ui components

* make checkbox more accessible and create e2e test around creating user

* add react testing library and use it for radio testing

* clean up comments

* update docs and clean up
2021-03-31 11:58:38 -07:00

34 lines
850 B
TypeScript

import React from 'react';
import { render, screen } from '@testing-library/react';
import Radio from './Radio';
describe('Radio - component', () => {
it('renders the correct selected state', () => {
render(<Radio
checked
label={'Test Radio'}
value={'Test Radio'}
id={'test-radio'}
onChange={() => { return null; }}
name={'Test Radio'}
/>);
const radio = screen.getByRole('radio', { name: 'Test Radio' });
expect(radio).toBeChecked();
});
it('renders the correct disabled state', () => {
render(<Radio
disabled
label={'Test Radio'}
value={'Test Radio'}
id={'test-radio'}
onChange={() => { return null; }}
name={'Test Radio'}
/>);
const radio = screen.getByRole('radio', { name: 'Test Radio' });
expect(radio).toBeDisabled();
});
});