@@ -2,11 +2,33 @@ import expect from 'expect'
2
2
import React from 'react'
3
3
import { renderToStaticMarkup as render } from 'react-dom/server'
4
4
5
+ import { configure , mount } from 'enzyme'
6
+ import Adapter from 'enzyme-adapter-react-16'
7
+ import sinon from 'sinon' ;
8
+
5
9
import AppSidebarToggler from 'src/SidebarToggler' ;
6
10
11
+ configure ( { adapter : new Adapter ( ) } ) ;
12
+
7
13
describe ( 'AppSidebarToggler' , ( ) => {
8
14
it ( 'renders button with class="navbar-toggler"' , ( ) => {
9
15
expect ( render ( < AppSidebarToggler className = "d-lg-none" display = "md" mobile /> ) )
10
16
. toContain ( '<button type="button" class="d-lg-none navbar-toggler"><span class="navbar-toggler-icon"></span></button>' )
11
17
} )
12
- } )
18
+ it ( 'should call sidebarToggle' , ( ) => {
19
+ let component = mount ( < AppSidebarToggler /> ) ;
20
+ const instance = component . instance ( ) ;
21
+ const handleClickSpy = sinon . spy ( instance , 'sidebarToggle' ) ;
22
+ component . find ( 'button' ) . simulate ( 'click' ) ;
23
+
24
+ expect ( handleClickSpy . called ) . toBe ( true ) ;
25
+ } )
26
+ it ( 'should call sidebarToggle mobile' , ( ) => {
27
+ let component = mount ( < AppSidebarToggler mobile /> ) ;
28
+ const instance = component . instance ( ) ;
29
+ const handleClickSpy = sinon . spy ( instance , 'sidebarToggle' ) ;
30
+ component . find ( 'button' ) . simulate ( 'click' ) ;
31
+
32
+ expect ( handleClickSpy . called ) . toBe ( true ) ;
33
+ } )
34
+ } )
0 commit comments