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