Skip to content

Instantly share code, notes, and snippets.

@mknabe
Last active April 27, 2018 07:24
Show Gist options
  • Select an option

  • Save mknabe/19be7277a8612e4a9ef9e3334cca54c9 to your computer and use it in GitHub Desktop.

Select an option

Save mknabe/19be7277a8612e4a9ef9e3334cca54c9 to your computer and use it in GitHub Desktop.

Revisions

  1. mknabe revised this gist Aug 9, 2017. 2 changed files with 20 additions and 6 deletions.
    6 changes: 0 additions & 6 deletions call-component-method.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +0,0 @@
    /*
    Call a component method
    https://github.com/airbnb/enzyme/issues/208#issuecomment-187313486
    */

    const wrapper = shallow(<Button />); wrapper.instance().handleClick()
    20 changes: 20 additions & 0 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    /*
    Call a component method
    https://github.com/airbnb/enzyme/issues/208#issuecomment-187313486
    */

    const wrapper = shallow(<Button />); wrapper.instance().handleClick();

    /*
    Re-render component after calling setState
    https://github.com/airbnb/enzyme/issues/450#issuecomment-225075145
    */

    expect(wrapper.update().find('#counter').text()).to.equal('1');

    /*
    Pass props to event handler
    https://github.com/airbnb/enzyme/issues/400
    */

    wrapper.find('Select').simulate('change', { target: { value: 'text' }});
  2. mknabe created this gist Aug 9, 2017.
    6 changes: 6 additions & 0 deletions call-component-method.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    /*
    Call a component method
    https://github.com/airbnb/enzyme/issues/208#issuecomment-187313486
    */

    const wrapper = shallow(<Button />); wrapper.instance().handleClick()