Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 9fb1921

Browse files
committed
test(select): add check for correct id passing
refs #484
1 parent 9925469 commit 9fb1921

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/chakra-ui-core/src/CSelect/tests/CSelect.test.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const renderComponent = (props) => {
66
const base = {
77
data: () => ({ value: 'option1' }),
88
components: { CSelect },
9-
template: `<CSelect data-testid="select" placeholder="input placeholder" v-model="value" ${inlineAttrs}>
9+
template: `<CSelect data-testid="select" id="selectTest" placeholder="input placeholder" v-model="value" ${inlineAttrs}>
1010
<option value="option1">Option 1</option>
1111
<option value="option2">Option 2</option>
1212
<option value="option3">Option 3</option>
@@ -27,3 +27,12 @@ test('disabled select renders correctly', () => {
2727

2828
expect(select).toHaveAttribute('disabled')
2929
})
30+
31+
test('passes the ID directly to the select and not to the wrapper', () => {
32+
renderComponent()
33+
const select = screen.getByRole('combobox')
34+
const selectWrapper = screen.getByTestId('select')
35+
36+
expect(select).toHaveAttribute('id')
37+
expect(selectWrapper).not.toHaveAttribute('id')
38+
})

packages/chakra-ui-core/src/CSelect/tests/__snapshots__/CSelect.test.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ exports[`should render correctly 1`] = `
134134
class="emotion-1"
135135
data-chakra-component="CSelectInput"
136136
datatestid="select"
137+
id="selectTest"
137138
value="option1"
138139
>
139140
<option

0 commit comments

Comments
 (0)