Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
esauerbo committed Sep 20, 2023
1 parent e87ce43 commit 792b4f2
Showing 1 changed file with 24 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,27 @@ describe('RadioFieldGroup', () => {
);
});

describe('Label', () => {
it('should render visually-hidden legend element with label name', async () => {
describe('Legend', () => {
it('should render visually-hidden legend element with legend name', async () => {
render(RadioFieldGroup({ ...basicProps }));

const labelElement = await screen.findAllByText(basicProps.legend);
expect(labelElement[0].nodeName).toBe('LEGEND');
const legendElement = await screen.findAllByText(basicProps.legend);
expect(legendElement[0].nodeName).toBe('LEGEND');
});

it('should have `amplify-fieldset__legend` classname', async () => {
render(RadioFieldGroup({ ...basicProps, labelHidden: true }));
render(RadioFieldGroup({ ...basicProps, legendHidden: true }));

const labelElement = await screen.findAllByText(basicProps.legend);
const legendElement = await screen.findAllByText(basicProps.legend);

expect(labelElement[1]).toHaveClass('amplify-fieldset__legend');
expect(legendElement[1]).toHaveClass('amplify-fieldset__legend');
});

it('should have `amplify-visually-hidden` class when labelHidden is true', async () => {
render(RadioFieldGroup({ ...basicProps, labelHidden: true }));
it('should have `amplify-visually-hidden` class when legendHidden is true', async () => {
render(RadioFieldGroup({ ...basicProps, legendHidden: true }));

const labelElement = await screen.findAllByText(basicProps.legend);
// expect(labelElement[1]).toHaveClass('amplify-visually-hidden');
// expect(
// labelElement[1].classList.contains('amplify-visually-hidden')
// ).toBe(true);
expect(labelElement[1].classList).toContain('amplify-visually-hidden');
const legendElement = await screen.findAllByText(basicProps.legend);
expect(legendElement[1]).toHaveClass('amplify-visually-hidden');
});
});

Expand Down Expand Up @@ -183,25 +179,21 @@ describe('RadioFieldGroup', () => {
render(RadioFieldGroup({ ...basicProps, size: 'large' }));

const radioField = await screen.findByTestId(basicProps.testId);
// expect(radioField).toHaveAttribute('size', 'large');
// expect(radioField).toHaveClass(
// `${ComponentClassName['Fieldset']}--large`
// );
expect(radioField).toContain(`${ComponentClassName['Fieldset']}--large`);
expect(radioField).toHaveClass(
`${ComponentClassName['Fieldset']}--large`
);

const radioButtons = await screen.findAllByTestId('radio-button');
expect(radioButtons[0]).toHaveAttribute('size', 'large');
expect(radioButtons[1]).toHaveAttribute('size', 'large');
expect(radioButtons[2]).toHaveAttribute('size', 'large');
// expect(radioButtons[0]).toContain(
// `${ComponentClassName['Field']}--large`
// );
// expect(radioButtons[1]).toContain(
// `${ComponentClassName['Field']}--large`
// );
// expect(radioButtons[2]).toContain(
// `${ComponentClassName['Field']}--large`
// );

expect(radioButtons[0]).toHaveClass(
`${ComponentClassName['RadioButton']}--large`
);
expect(radioButtons[1]).toHaveClass(
`${ComponentClassName['RadioButton']}--large`
);
expect(radioButtons[2]).toHaveClass(
`${ComponentClassName['RadioButton']}--large`
);
});

it('should render size classes for RadioGroupField', async () => {
Expand Down

0 comments on commit 792b4f2

Please sign in to comment.