Skip to content

Commit ff7c4fe

Browse files
committed
tests: update tests
1 parent e829fdf commit ff7c4fe

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

src/components/toast/__tests__/CToast.spec.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ test('CToast customize', async () => {
1515
autohide={false}
1616
color="warning"
1717
delay={100}
18-
key={1}
1918
visible={true}
2019
//onDismiss
2120
>
@@ -41,7 +40,6 @@ test('CToast click on dismiss button', async () => {
4140
autohide={false}
4241
color="warning"
4342
delay={100}
44-
key={1}
4543
visible={true}
4644
onDismiss={onDismiss}
4745
>

src/components/tooltip/__tests__/CTooltip.spec.tsx

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
11
import * as React from 'react'
2-
import { act, render, fireEvent } from '@testing-library/react'
2+
import ReactDOM from 'react-dom'
3+
import { act } from 'react-dom/test-utils'
4+
import { fireEvent } from '@testing-library/react'
35
import '@testing-library/jest-dom/extend-expect'
46
import { CTooltip, CLink } from '../../../index'
57

8+
let container: HTMLDivElement | null
9+
10+
beforeEach(() => {
11+
container = document.createElement('div')
12+
document.body.appendChild(container)
13+
})
14+
15+
afterEach(() => {
16+
container && document.body.removeChild(container)
17+
container = null
18+
})
19+
620
test('loads and displays CTooltip component', async () => {
7-
const { container } = render(
21+
ReactDOM.render(
822
<CTooltip content="content">
923
<CLink>Test</CLink>
1024
</CTooltip>,
25+
container,
1126
)
1227
expect(container).toMatchSnapshot()
1328
})
1429

1530
test('CTooltip customize', async () => {
16-
const { container } = render(
17-
<CTooltip trigger="hover" placement="right" content="content">
18-
<CLink className="link">Test</CLink>
19-
</CTooltip>,
20-
)
31+
act(() => {
32+
ReactDOM.render(
33+
<CTooltip trigger="hover" placement="right" content="content">
34+
<CLink className="link">Test</CLink>
35+
</CTooltip>,
36+
container,
37+
)
38+
})
2139
const link = document.querySelector('.link')
2240
act(() => {
2341
if (link !== null) {

0 commit comments

Comments
 (0)