Skip to content

Commit

Permalink
Update select.test.tsx to include test of for attribute association
Browse files Browse the repository at this point in the history
Co-authored-by: Johannes Weber <jwebe0pe@gmail.com>
  • Loading branch information
jorycunningham and johannes-weber authored Jun 26, 2024
1 parent 082f244 commit 74665a1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/select/__tests__/select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,18 @@ describe.each([false, true])('expandToViewport=%s', expandToViewport => {
expect(labelElement?.getElement()).toHaveTextContent(testLabel);
expect(labelElement?.getElement().tagName).toBe('LABEL');
});
test('associate label with trigger button', () => {
const testLabel = 'Test label';
const { wrapper } = renderSelect({ inlineLabelText: testLabel });

const labelForAttribute = wrapper
.findByClassName(selectPartsStyles['inline-label'])!
.getElement()!
.getAttribute('for');
const triggerId = wrapper.findTrigger().getElement()!.id;

expect(labelForAttribute).toBe(triggerId);
});
});

test('should render with focus when autoFocus=true', () => {
Expand Down

0 comments on commit 74665a1

Please sign in to comment.