How to use the react-testing-library.Simulate.change function in react-testing-library

To help you get started, we’ve selected a few react-testing-library examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ticketmaster / aurora / src / components / Input / __tests__ / QtySelector.spec.js View on Github external
it("handles input value longer than 2 chars correctly when using buttons", () => {
    const { container } = renderQtySelectorComponent();
    const input = container.getElementsByTagName("input")[0];
    const button = container.getElementsByTagName("button")[1];

    Simulate.change(input, {
      target: { value: "99" }
    });
    Simulate.click(button);

    expect(container.firstChild).toMatchSnapshot();
  });
github autonomoussoftware / metronome-wallet-desktop / src / testUtils.js View on Github external
Object.keys(formData).forEach((fieldId, i) => {
    const field = getter(fieldId)
    field.value = formData[fieldId]
    Simulate.change(field)
  })
github ensdomains / ens-app / src / components / SearchName / __tests__ / SearchName.js View on Github external
const { getByText, container } = renderIntoDocument(
    
      
    
  )

  const form = container.querySelector('form')
  const submitButton = getByText('Search for domain')
  const domainName = form.querySelector('input[type=text]')

  //act
  domainName.value = 'vitalik.eth'
  Simulate.change(domainName)
  submitButton.click()

  //assert
  expect(handleGetNodeDetails).toHaveBeenCalledTimes(1)
  //expect(handleGetNodeDetails).toHaveBeenCalledWith('vitalik.eth', mockClient, addNotification)
  expect(submitButton.type).toBe('submit')
  expect(domainName.value).toBe('')
})