|
1 | 1 | import React from 'react'
|
2 | 2 | import { configure, mount } from 'enzyme'
|
3 | 3 | import Adapter from 'enzyme-adapter-react-16'
|
4 |
| -import renderer from 'react-test-renderer'; |
| 4 | +import { create } from 'react-test-renderer'; |
| 5 | +import { act } from 'react-dom/test-utils'; |
5 | 6 |
|
6 | 7 | import CToast from '../CToast'
|
7 | 8 | import CToaster from '../CToaster'
|
@@ -10,12 +11,12 @@ configure({ adapter: new Adapter() })
|
10 | 11 |
|
11 | 12 | describe('CToast', () => {
|
12 | 13 | it('renders basic wrapper correctly', () => {
|
13 |
| -const component = renderer.create(<CToast/>); |
| 14 | +const component = create(<CToast/>); |
14 | 15 | let tree = component.toJSON();
|
15 | 16 | expect(tree).toMatchSnapshot()
|
16 | 17 | })
|
17 | 18 | it('renders customized wrapper correctly', () => {
|
18 |
| -const componentCustomized = renderer.create( |
| 19 | +const componentCustomized = create( |
19 | 20 | <CToast
|
20 | 21 | className='class-name'
|
21 | 22 | show
|
@@ -44,7 +45,9 @@ describe('CToast', () => {
|
44 | 45 | </CToast>
|
45 | 46 | </CToaster>
|
46 | 47 | );
|
47 |
| -jest.runAllTimers() |
| 48 | +act(() => { |
| 49 | +jest.runAllTimers() |
| 50 | +}) |
48 | 51 | console.log(component.html());
|
49 | 52 | expect(component.find(<CToast/>)).toHaveLength(0);
|
50 | 53 | })
|
@@ -64,8 +67,10 @@ describe('CToast', () => {
|
64 | 67 | </CToast>
|
65 | 68 | </CToaster>
|
66 | 69 | );
|
67 |
| -jest.runAllTimers() |
| 70 | +act(() => { |
| 71 | +jest.runAllTimers() |
| 72 | +}) |
68 | 73 | console.log(component.html());
|
69 | 74 | expect(component.find(<CToast/>)).toHaveLength(0);
|
70 | 75 | })
|
71 |
| -}) |
| 76 | +}) |
0 commit comments