Skip to content

Commit dd120af

Browse files
committed
change react-testing-library to @testing-library/react in Modal tests
1 parent 0f6b2d9 commit dd120af

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

react/components/Modal/index.test.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { render, fireEvent, screen } from 'react-testing-library'
2+
import { render, fireEvent } from '@testing-library/react'
33

44
import Modal from '.'
55

@@ -59,8 +59,7 @@ describe('Modal', () => {
5959
render(
6060
<Modal isOpen onClose={onClose}>
6161
Foo
62-
</Modal>,
63-
{ container: document.body }
62+
</Modal>
6463
)
6564
fireEvent.click(document.querySelector('.vtex-modal__overlay'))
6665
expect(onClose).toHaveBeenCalled()
@@ -72,8 +71,7 @@ describe('Modal', () => {
7271
render(
7372
<Modal isOpen onClose={onClose} closeOnOverlayClick={false}>
7473
Foo
75-
</Modal>,
76-
{ container: document.body }
74+
</Modal>
7775
)
7876
fireEvent.click(document.querySelector('.vtex-modal__overlay'))
7977
expect(onClose).not.toHaveBeenCalled()
@@ -164,6 +162,7 @@ describe('Modal', () => {
164162
// help it's not working
165163
// describe('onCloseTransitionFinish', () => {
166164
// it('should be called after 500ms', () => {
165+
// jest.useFakeTimers()
167166
// const onClose = jest.fn()
168167
// const onCloseTransitionFinish = jest.fn()
169168

@@ -178,7 +177,7 @@ describe('Modal', () => {
178177
// )
179178

180179
// fireEvent.keyDown(container, { key: 'Escape', keyCode: 27 })
181-
// // jest.runAllTimers()
180+
// jest.runAllTimers()
182181
// expect(onCloseTransitionFinish).toHaveBeenCalled()
183182
// })
184183
// })

react/components/ModalDialog/index.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { render, fireEvent } from 'react-testing-library'
2+
import { render, fireEvent } from '@testing-library/react'
33

44
import ModalDialog from '.'
55

@@ -12,7 +12,7 @@ describe('ModalDialog', () => {
1212
it('should render label', () => {
1313
const onCancel = jest.fn()
1414
const cancelLabel = 'cancel'
15-
const { getByText, container } = render(
15+
const { getAllByText, container } = render(
1616
<ModalDialog
1717
isOpen
1818
cancelation={{
@@ -28,7 +28,7 @@ describe('ModalDialog', () => {
2828
</ModalDialog>,
2929
{ container: document.body }
3030
)
31-
expect(getByText(cancelLabel)).not.toBeNull()
31+
expect(getAllByText(cancelLabel)).not.toBeNull()
3232
expect(container).toMatchSnapshot()
3333
})
3434

@@ -61,7 +61,7 @@ describe('ModalDialog', () => {
6161
it('should render label', () => {
6262
const onConfirm = jest.fn()
6363
const confirmLabel = 'cancel'
64-
const { getByText, container } = render(
64+
const { getAllByText, container } = render(
6565
<ModalDialog
6666
isOpen
6767
cancelation={{
@@ -77,7 +77,7 @@ describe('ModalDialog', () => {
7777
</ModalDialog>,
7878
{ container: document.body }
7979
)
80-
expect(getByText(confirmLabel)).not.toBeNull()
80+
expect(getAllByText(confirmLabel)).not.toBeNull()
8181
expect(container).toMatchSnapshot()
8282
})
8383

0 commit comments

Comments
 (0)