Answers for "how to simulate dropodown click in react testing"

0

how to simulate dropodown click in react testing

document.body.innerHTML = `
      <select>
        <option value="hello">Hello</option>
        <option value="goodbye" selected>Goodbye</option>
      </select>
    `;
    const props = {
      node: document.querySelector('select'),
    };
    const wrapper = mount(<Component {...props} />);
    expect(wrapper.render().find('select [selected]').val()).to.equal('goodbye');
    wrapper.find('select').node.value = 'hello';
    wrapper.find('select').simulate('change');
    expect(wrapper.render().find('select [selected]').val()).to.equal('hello');
  });
Posted by: Guest on May-25-2021

Code answers related to "how to simulate dropodown click in react testing"

Code answers related to "Javascript"

Browse Popular Code Answers by Language