11import React from 'react'
22import { configure , mount } from 'enzyme'
33import 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' ;
56
67import CToast from '../CToast'
78import CToaster from '../CToaster'
@@ -10,12 +11,12 @@ configure({ adapter: new Adapter() })
1011
1112describe ( 'CToast' , ( ) => {
1213 it ( 'renders basic wrapper correctly' , ( ) => {
13- const component = renderer . create ( < CToast /> ) ;
14+ const component = create ( < CToast /> ) ;
1415 let tree = component . toJSON ( ) ;
1516 expect ( tree ) . toMatchSnapshot ( )
1617 } )
1718 it ( 'renders customized wrapper correctly' , ( ) => {
18- const componentCustomized = renderer . create (
19+ const componentCustomized = create (
1920 < CToast
2021 className = 'class-name'
2122 show
@@ -44,7 +45,9 @@ describe('CToast', () => {
4445 </ CToast >
4546 </ CToaster >
4647 ) ;
47- jest . runAllTimers ( )
48+ act ( ( ) => {
49+ jest . runAllTimers ( )
50+ } )
4851 console . log ( component . html ( ) ) ;
4952 expect ( component . find ( < CToast /> ) ) . toHaveLength ( 0 ) ;
5053 } )
@@ -64,8 +67,10 @@ describe('CToast', () => {
6467 </ CToast >
6568 </ CToaster >
6669 ) ;
67- jest . runAllTimers ( )
70+ act ( ( ) => {
71+ jest . runAllTimers ( )
72+ } )
6873 console . log ( component . html ( ) ) ;
6974 expect ( component . find ( < CToast /> ) ) . toHaveLength ( 0 ) ;
7075 } )
71- } )
76+ } )
0 commit comments