showing results for - "how to simulate dropodown click in react testing"
Tom
04 Oct 2016
1document.body.innerHTML = `
2      <select>
3        <option value="hello">Hello</option>
4        <option value="goodbye" selected>Goodbye</option>
5      </select>
6    `;
7    const props = {
8      node: document.querySelector('select'),
9    };
10    const wrapper = mount(<Component {...props} />);
11    expect(wrapper.render().find('select [selected]').val()).to.equal('goodbye');
12    wrapper.find('select').node.value = 'hello';
13    wrapper.find('select').simulate('change');
14    expect(wrapper.render().find('select [selected]').val()).to.equal('hello');
15  });