Skip to content

Commit 139af29

Browse files
authored
[test] Fix non-native label tests (#3786)
1 parent f2b4c59 commit 139af29

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

packages/react/src/autocomplete/root/AutocompleteRoot.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,7 @@ describe('<Autocomplete.Root />', () => {
16041604
<Autocomplete.Positioner />
16051605
</Autocomplete.Portal>
16061606
</Autocomplete.Root>
1607-
<Field.Label data-testid="label" render={<span />} />
1607+
<Field.Label data-testid="label" render={<span />} nativeLabel={false} />
16081608
</Field.Root>,
16091609
);
16101610

packages/react/src/switch/root/SwitchRoot.test.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -814,22 +814,19 @@ describe('<Switch.Root />', () => {
814814
it('when rendering a non-native label', async () => {
815815
await render(
816816
<Field.Root>
817-
<Field.Label data-testid="label" render={<span />}>
817+
<Field.Label data-testid="label" render={<span />} nativeLabel={false}>
818818
<Switch.Root data-testid="button" />
819819
</Field.Label>
820820
</Field.Root>,
821821
);
822822

823823
const label = screen.getByTestId('label');
824824
const switchEl = screen.getByRole('switch');
825-
const input = document.querySelector('input[type="checkbox"]');
826825

827-
expect(label.getAttribute('for')).not.to.equal(null);
826+
expect(label.getAttribute('for')).to.equal(null);
828827
expect(label.getAttribute('id')).not.to.equal(null);
829828

830-
expect(label.getAttribute('for')).to.equal(input?.getAttribute('id'));
831829
expect(switchEl.getAttribute('aria-labelledby')).to.equal(label.getAttribute('id'));
832-
833830
expect(switchEl).to.have.attribute('aria-checked', 'false');
834831

835832
// non-native labels cannot toggle a non-native-button switch

0 commit comments

Comments
 (0)