import React from 'react' ; import { shallow } from 'enzyme' ; import { YesNo } from './yes_no' ; describe ( 'YesNo' , ( ) => { it ( 'call onChange={handleChange} on yes' , ( ) => { const handleChange = jest . fn ( ) ; const wrapper = shallow ( < YesNo name = "ignore_global_filters" onChange = { handleChange } value = { 0 } / > ) ; wrapper . find ( 'EuiRadio' ) . first ( ) . simulate ( 'change' ) ; expect ( handleChange ) . toHaveBeenCalledTimes ( 1 ) ; expect ( handleChange ) . toHaveBeenCalledWith ( { ignore_global_filters : 1 , } ) ; } ) ; it ( 'call onChange={handleChange} on no' , ( ) => { const handleChange = jest . fn ( ) ; const wrapper = shallow ( < YesNo name = "show_legend" onChange = { handleChange } value = { 1 } / > ) ; wrapper . find ( 'EuiRadio' ) . last ( ) . simulate ( 'change' ) ; expect ( handleChange ) . toHaveBeenCalledTimes ( 1 ) ; expect ( handleChange ) . toHaveBeenCalledWith ( { show_legend : 0 , } ) ; } ) ; } ) ;