@@ -2,11 +2,33 @@ import expect from 'expect'
22import React from 'react'
33import { renderToStaticMarkup as render } from 'react-dom/server'
44
5+ import { configure , mount } from 'enzyme'
6+ import Adapter from 'enzyme-adapter-react-16'
7+ import sinon from 'sinon' ;
8+
59import AppSidebarToggler from 'src/SidebarToggler' ;
610
11+ configure ( { adapter : new Adapter ( ) } ) ;
12+
713describe ( 'AppSidebarToggler' , ( ) => {
814 it ( 'renders button with class="navbar-toggler"' , ( ) => {
915 expect ( render ( < AppSidebarToggler className = "d-lg-none" display = "md" mobile /> ) )
1016 . toContain ( '<button type="button" class="d-lg-none navbar-toggler"><span class="navbar-toggler-icon"></span></button>' )
1117 } )
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