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

Commit 7b3d85f

Browse files
committed
test(checkbox-group): refactor CheckboxGroup tests
1 parent 068420c commit 7b3d85f

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CBox, CCheckbox, CCheckboxGroup } from '../..'
2-
import { render } from '@/tests/test-utils'
2+
import { render, screen, wait } from '@/tests/test-utils'
33

44
// mocks
55
import { useId } from '@/packages/chakra-ui-core/src/utils'
@@ -33,20 +33,18 @@ it('should render correctly', () => {
3333
})
3434

3535
it('should display children', () => {
36-
const { getByText } = renderComponent()
37-
expect(getByText('One')).toBeInTheDocument()
38-
expect(getByText('Two')).toBeInTheDocument()
39-
expect(getByText('Three')).toBeInTheDocument()
36+
renderComponent()
37+
expect(screen.getByText('One')).toBeInTheDocument()
38+
expect(screen.getByText('Two')).toBeInTheDocument()
39+
expect(screen.getByText('Three')).toBeInTheDocument()
4040
})
4141

4242
test('selectedValues prop works', () => {
43-
const { getByTestId } = renderComponent()
43+
renderComponent()
4444

45-
const one = getByTestId('one').querySelector('input')
46-
const two = getByTestId('two').querySelector('input')
47-
const three = getByTestId('three').querySelector('input')
48-
49-
expect(one).not.toBeChecked()
50-
expect(two).toBeChecked()
51-
expect(three).not.toBeChecked()
45+
wait(() => {
46+
expect(screen.getByLabelText('One')).not.toBeChecked()
47+
expect(screen.getByLabelText('Two')).toBeChecked()
48+
expect(screen.getByLabelText('Three')).not.toBeChecked()
49+
})
5250
})

0 commit comments

Comments
 (0)