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 renderer from 'react-test-renderer'
55
66import CTooltip from '../CTooltip'
77
88configure ( { adapter : new Adapter ( ) } )
99
10+ beforeAll ( ( ) => {
11+ // Avoid `attachTo: document.body` Warning
12+ const div = document . createElement ( 'div' )
13+ div . setAttribute ( 'id' , 'container' )
14+ document . body . appendChild ( div )
15+ } )
16+
17+ afterAll ( ( ) => {
18+ const div = document . getElementById ( 'container' )
19+ if ( div ) {
20+ document . body . removeChild ( div )
21+ }
22+ } )
23+
1024describe ( 'CTooltip' , ( ) => {
1125 it ( 'renders basic wrapper correctly' , ( ) => {
12- const component = renderer . create ( < CTooltip > CTooltip</ CTooltip > ) ;
13- let tree = component . toJSON ( ) ;
14- expect ( tree ) . toMatchSnapshot ( )
26+ const wrapper = renderer . create (
27+ < CTooltip content = "tooltip" >
28+ < div > CTooltip</ div >
29+ </ CTooltip > ,
30+ { attachTo : document . getElementById ( 'container' ) }
31+ )
32+ expect ( wrapper ) . toBeTruthy ( )
1533 } )
1634 it ( 'renders customized wrapper correctly' , ( ) => {
17- const componentCustomized = renderer . create (
18- < CTooltip
19- className = 'class-name'
20- content = 'content'
35+ const wrapper = mount ( < CTooltip
36+ className = "class-name"
37+ content = "content"
2138 interactive
22- placement = ' left-end'
23- trigger = ' trigger'
39+ placement = " left-end"
40+ trigger = " trigger"
2441 >
25- CTooltip
26- </ CTooltip >
27- ) ;
28- let tree = componentCustomized . toJSON ( ) ;
29- expect ( tree ) . toMatchSnapshot ( )
42+ < div > CTooltip</ div >
43+ </ CTooltip > ,
44+ { attachTo : document . getElementById ( 'container' ) }
45+ )
46+ expect ( wrapper ) . toBeTruthy ( )
3047 } )
3148} )
0 commit comments