Skip to content

Commit

Permalink
test(component): Add unit test for <Label value="">
Browse files Browse the repository at this point in the history
  • Loading branch information
tulup-conner committed Jun 6, 2022
1 parent c469f99 commit 2463cc0
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/lib/components/FormControls/Label.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { render } from '@testing-library/react';
import { HiGlobe, HiLockClosed } from 'react-icons/hi';
import { describe, expect, it } from 'vitest';

import { Button } from '../Button';
import { Checkbox } from './Checkbox';
import { FileInput } from './FileInput';
Expand All @@ -13,14 +12,8 @@ import { TextInput } from './TextInput';
import { ToggleSwitch } from './ToggleSwitch';

describe.concurrent('Components / Form controls / Label', () => {
it('should render', () => {
render(<Label>Hello</Label>);
});

describe('A11y', () => {
it('should provide accessible name to any form control associated by `htmlFor`', () => {
const { getByLabelText } = render(<TestForm />);

const inputLabels = [
'Your email',
'Your password',
Expand All @@ -31,9 +24,23 @@ describe.concurrent('Components / Form controls / Label', () => {
'Your message',
];

const { getByLabelText } = render(<TestForm />);

inputLabels.forEach((label) => expect(getByLabelText(label)).toHaveAccessibleName(label));
});
});

describe('Rendering', () => {
it('should render', () => {
render(<Label>Hello</Label>);
});

describe('`value=".."`', () => {
it('should render', () => {
render(<Label value="Hello" />);
});
});
});
});

const TestForm = (): JSX.Element => (
Expand Down

0 comments on commit 2463cc0

Please sign in to comment.