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

Commit a77f8f3

Browse files
committed
test(close-button): refactor close button tests
1 parent d14721c commit a77f8f3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/chakra-ui-core/src/CCloseButton/tests/CloseButton.test.js

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

44
const renderComponent = (props) => {
55
const base = {
@@ -14,18 +14,18 @@ it('should render correctly', () => {
1414
expect(asFragment()).toMatchSnapshot()
1515
})
1616
it('should allow setting a custom aria-label for the button', () => {
17-
const { container } = renderComponent({ template: '<CloseButton aria-label="my aria label" />' })
17+
renderComponent({ template: '<CloseButton aria-label="my aria label" />' })
1818

19-
expect(container.querySelector('button')).toHaveAttribute(
19+
expect(screen.getByLabelText('my aria label')).toHaveAttribute(
2020
'aria-label',
2121
'my aria label'
2222
)
2323
})
2424

2525
test('a11y - should have aria-label set to "Close"', () => {
26-
const { container } = renderComponent()
26+
renderComponent()
2727

28-
expect(container.querySelector('button')).toHaveAttribute(
28+
expect(screen.getByLabelText('Close')).toHaveAttribute(
2929
'aria-label',
3030
'Close'
3131
)

0 commit comments

Comments
 (0)