mercredi 19 octobre 2016

enzyme check checkbox status

I have following example component

export default class Header extends Component{

render(){
  let activeStyle   = {"backgroundColor": "green"};
  let inActiveStyle = {"backgroundColor": "red"};
  return(
    <div className="profile-header" style={(this.props.active)?
      activeStyle:inActiveStyle}>
      <input type="checkbox" checked={this.props.active} readOnly/>
  </div>
 );
}
}

Using Enzyme and chai I would like to assert, that for

this.props.active = true 

The backgroundColor is green and the checkbox is checked.

Here's my test case

describe('<Header />', () => {
  it('valid component', () => {
    const wrapper = shallow(<ProfileHeader
    active= {true}
    />);
   ????
  });

But how can I assert both cases?

Aucun commentaire:

Enregistrer un commentaire