1
1
import React from 'react'
2
2
import { configure , mount } from 'enzyme'
3
3
import Adapter from 'enzyme-adapter-react-16'
4
- import renderer from 'react-test-renderer' ;
4
+ import toJson from 'enzyme-to-json'
5
5
6
6
import CTabs from '../CTabs'
7
7
8
8
import 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'
12
12
import CTabContent from '../CTabContent'
13
13
14
14
configure ( { adapter : new Adapter ( ) } )
15
15
16
16
describe ( '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
+
34
18
it ( 'render full tabs' , ( ) => {
35
- const componentCustomized = renderer . create (
19
+ const wrapper = mount (
36
20
< CTabs activeTab = "home" >
37
21
< CNav variant = "tabs" >
38
22
< CNavItem >
@@ -63,12 +47,12 @@ describe('CTabs', () => {
63
47
</ CTabPane >
64
48
</ CTabContent >
65
49
</ CTabs >
66
- ) ;
67
- let tree = componentCustomized . toJSON ( ) ;
68
- expect ( tree ) . toMatchSnapshot ( )
69
- } ) ;
50
+ )
51
+ expect ( toJson ( wrapper ) ) . toMatchSnapshot ( )
52
+ } )
53
+
70
54
it ( 'onActiveTabChange' , ( ) => {
71
- const tabChange = jest . fn ( ) ;
55
+ const tabChange = jest . fn ( )
72
56
const component = mount (
73
57
< CTabs
74
58
activeTab = "home"
@@ -103,8 +87,8 @@ describe('CTabs', () => {
103
87
</ CTabPane >
104
88
</ CTabContent >
105
89
</ CTabs >
106
- ) ;
90
+ )
107
91
component . find ( '.nav-link' ) . at ( 1 ) . simulate ( 'click' )
108
92
expect ( tabChange ) . toHaveBeenCalledTimes ( 1 ) ;
109
- } ) ;
93
+ } )
110
94
} )
0 commit comments