Skip to content

Commit

Permalink
adds toBeLabelled to text input
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSonOfThomp committed Feb 15, 2024
1 parent cf8994c commit 7917785
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/text-input/src/TextInput/TextInput.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,27 @@ describe('packages/text-input', () => {
expect(results).toHaveNoViolations();
});
});

test(`renders ${defaultProps.label} as the input label and ${defaultProps.description} as the description`, () => {
const { label, description } = renderTextInput(defaultProps);
expect(label?.innerHTML).toContain(defaultProps.label);
expect(description?.innerHTML).toContain(defaultProps.description);
});

test('allows external label', () => {
const { getByTestId } = render(
<>
<label htmlFor="input" id="label">
Label
</label>
<TextInput data-testid="input" id="input" aria-labelledby="label" />
</>,
);

const input = getByTestId('input');
expect(input).toBeLabelled();
});

test(`renders ${defaultProps.placeholder} as placeholder text`, () => {
const { getByPlaceholderText } = renderTextInput(defaultProps);
expect(getByPlaceholderText(defaultProps.placeholder)).toBeVisible();
Expand Down

0 comments on commit 7917785

Please sign in to comment.