11import React from 'react'
22import { configure , mount } from 'enzyme'
33import 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+
57
68import CToast from '../CToast'
79import CToaster from '../CToaster'
@@ -10,12 +12,12 @@ configure({ adapter: new Adapter() })
1012
1113describe ( 'CToast' , ( ) => {
1214 it ( 'renders basic wrapper correctly' , ( ) => {
13- const component = renderer . create ( < CToast /> ) ;
15+ const component = create ( < CToast /> ) ;
1416 let tree = component . toJSON ( ) ;
1517 expect ( tree ) . toMatchSnapshot ( )
1618 } )
1719 it ( 'renders customized wrapper correctly' , ( ) => {
18- const componentCustomized = renderer . create (
20+ const componentCustomized = create (
1921 < CToast
2022 className = 'class-name'
2123 show
@@ -44,7 +46,9 @@ describe('CToast', () => {
4446 </ CToast >
4547 </ CToaster >
4648 ) ;
47- jest . runAllTimers ( )
49+ act ( ( ) => {
50+ jest . runAllTimers ( )
51+ } )
4852 console . log ( component . html ( ) ) ;
4953 expect ( component . find ( < CToast /> ) ) . toHaveLength ( 0 ) ;
5054 } )
@@ -64,7 +68,9 @@ describe('CToast', () => {
6468 </ CToast >
6569 </ CToaster >
6670 ) ;
67- jest . runAllTimers ( )
71+ act ( ( ) => {
72+ jest . runAllTimers ( )
73+ } )
6874 console . log ( component . html ( ) ) ;
6975 expect ( component . find ( < CToast /> ) ) . toHaveLength ( 0 ) ;
7076 } )
0 commit comments