File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -84,8 +84,7 @@ class AppSwitch extends Component {
8484
8585 return (
8686 < label className = { classes } >
87- < input type = { type } className = { inputClasses } onChange = { this . toggle } checked = { this . state . checked } defaultChecked = { defaultChecked } name = { name }
88- required = { required } disabled = { disabled } value = { value } />
87+ < input type = { type } className = { inputClasses } onChange = { this . toggle } checked = { this . state . checked } name = { name } required = { required } disabled = { disabled } value = { value } />
8988 < span className = { sliderClasses } data-checked = { dataOn } data-unchecked = { dataOff } > </ span >
9089 </ label >
9190 ) ;
Original file line number Diff line number Diff line change 1+ import expect from 'expect'
2+ import React from 'react'
3+ import { renderToStaticMarkup as render } from 'react-dom/server'
4+
5+ import { configure , mount } from 'enzyme'
6+ import Adapter from 'enzyme-adapter-react-16'
7+ import { spy } from 'sinon'
8+
9+ import AppSwitch from 'src/Switch'
10+
11+ configure ( { adapter : new Adapter ( ) } ) ;
12+
13+ describe ( 'AppSwitch' , ( ) => {
14+ it ( 'renders label with class="switch"' , ( ) => {
15+ expect ( render ( < AppSwitch /> ) )
16+ . toContain ( '<label class="switch' )
17+ } ) ;
18+ it ( 'should call toggle' , ( ) => {
19+ const onChange = spy ( AppSwitch . prototype , 'toggle' ) ;
20+ const event = { target : { checked : true } } ;
21+ const wrapper = mount ( < AppSwitch outlineAlt label pill size = "lg" /> ) ;
22+ expect ( wrapper . find ( 'input' ) . props ( ) . checked ) . toBe ( false ) ;
23+ wrapper . find ( 'input' ) . simulate ( 'change' , event )
24+ expect ( onChange . called ) . toBe ( true ) ;
25+ expect ( wrapper . find ( 'input' ) . props ( ) . checked ) . toBe ( true ) ;
26+
27+ } )
28+ } )
You can’t perform that action at this time.
0 commit comments