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 toJson from 'enzyme-to-json'
55
66import CTabs from '../CTabs'
77
88import CTabPane from '../CTabPane'
9- import CNav from '../CNav'
10- import CNavItem from '../CNavItem'
11- import CNavLink from '../CNavLink'
9+ import CNav from '../../nav/ CNav'
10+ import CNavItem from '../../nav/ CNavItem'
11+ import CNavLink from '../../nav/ CNavLink'
1212import CTabContent from '../CTabContent'
1313
1414configure ( { adapter : new Adapter ( ) } )
1515
1616describe ( 'CTabs' , ( ) => {
17- it ( 'renders basic wrapper correctly' , ( ) => {
18- const component = renderer . create ( < CTabs /> ) ;
19- let tree = component . toJSON ( ) ;
20- expect ( tree ) . toMatchSnapshot ( )
21- } )
22- it ( 'renders customized wrapper correctly' , ( ) => {
23- const componentCustomized = renderer . create (
24- < CTabs
25- activeTab = 'first-one'
26- fade
27- >
28- CTabs
29- </ CTabs >
30- ) ;
31- let tree = componentCustomized . toJSON ( ) ;
32- expect ( tree ) . toMatchSnapshot ( )
33- } )
17+
3418 it ( 'render full tabs' , ( ) => {
35- const componentCustomized = renderer . create (
19+ const wrapper = mount (
3620 < CTabs activeTab = "home" >
3721 < CNav variant = "tabs" >
3822 < CNavItem >
@@ -63,12 +47,12 @@ describe('CTabs', () => {
6347 </ CTabPane >
6448 </ CTabContent >
6549 </ CTabs >
66- ) ;
67- let tree = componentCustomized . toJSON ( ) ;
68- expect ( tree ) . toMatchSnapshot ( )
69- } ) ;
50+ )
51+ expect ( toJson ( wrapper ) ) . toMatchSnapshot ( )
52+ } )
53+
7054 it ( 'onActiveTabChange' , ( ) => {
71- const tabChange = jest . fn ( ) ;
55+ const tabChange = jest . fn ( )
7256 const component = mount (
7357 < CTabs
7458 activeTab = "home"
@@ -103,8 +87,8 @@ describe('CTabs', () => {
10387 </ CTabPane >
10488 </ CTabContent >
10589 </ CTabs >
106- ) ;
90+ )
10791 component . find ( '.nav-link' ) . at ( 1 ) . simulate ( 'click' )
10892 expect ( tabChange ) . toHaveBeenCalledTimes ( 1 ) ;
109- } ) ;
93+ } )
11094} )
0 commit comments