How to use the @testing-library/dom.fireEvent.click function in @testing-library/dom

To help you get started, we’ve selected a few @testing-library/dom 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 Synerise / synerise-design / packages / components / sidebar / src / __specs__ / Sidebar.spec.tsx View on Github external
const { getByText, container } = renderWithProvider(
      
        
          {CHILDREN}
        
        
          {CHILDREN}
        
        
          {CHILDREN}
        
      
    );

    // ACT
    fireEvent.click(getByText(HEADER_1));
    fireEvent.click(getByText(HEADER_2));
    fireEvent.click(getByText(HEADER_3));

    // ASSERT
    expect(container.querySelectorAll('.ant-collapse-header')[0].textContent).toEqual(HEADER_3);
    expect(container.querySelectorAll('.ant-collapse-header')[1].textContent).toEqual(HEADER_2);
    expect(container.querySelectorAll('.ant-collapse-header')[2].textContent).toEqual(HEADER_1);
  });
});
github testing-library / user-event / src / index.js View on Github external
function clickBooleanElement(element) {
  if (element.disabled) return;

  fireEvent.mouseOver(element);
  fireEvent.mouseMove(element);
  fireEvent.mouseDown(element);
  fireEvent.focus(element);
  fireEvent.mouseUp(element);
  fireEvent.click(element);
}
github testing-library / user-event / src / index.js View on Github external
function dblClickElement(element) {
  fireEvent.mouseOver(element);
  fireEvent.mouseMove(element);
  fireEvent.mouseDown(element);
  element.focus();
  fireEvent.mouseUp(element);
  fireEvent.click(element);
  fireEvent.mouseDown(element);
  fireEvent.mouseUp(element);
  fireEvent.click(element);
  fireEvent.dblClick(element);

  const labelAncestor = findTagInParents(element, "LABEL");
  labelAncestor && clickLabel(labelAncestor);
}
github testing-library / user-event / src / index.js View on Github external
function clickElement(element) {
  fireEvent.mouseOver(element);
  fireEvent.mouseMove(element);
  fireEvent.mouseDown(element);
  element.focus();
  fireEvent.mouseUp(element);
  fireEvent.click(element);

  const labelAncestor = findTagInParents(element, "LABEL");
  labelAncestor && clickLabel(labelAncestor);
}
github testing-library / user-event / src / index.js View on Github external
function clickLabel(label) {
  fireEvent.mouseOver(label);
  fireEvent.mouseMove(label);
  fireEvent.mouseDown(label);
  fireEvent.mouseUp(label);

  if (label.htmlFor) {
    const input = document.getElementById(label.htmlFor);
    input.focus();
    fireEvent.click(label);
  } else {
    const input = label.querySelector("input,textarea,select");
    input.focus();
    label.focus();
    fireEvent.click(label);
  }
}
github jamaljsr / polar / src / components / designer / bitcoind / actions / MineBlocksInput.spec.tsx View on Github external
it('should display an error if blocks is below 1', async () => {
    const { input, btn, findByText } = renderComponent();
    const numBlocks = -5;
    fireEvent.change(input, { target: { value: numBlocks } });
    fireEvent.click(btn);
    expect(await findByText(/must be a positve number/)).toBeInTheDocument();
  });
github jamaljsr / polar / src / components / designer / lightning / actions / Deposit.spec.tsx View on Github external
it('should deposit funds when the button is clicked', async () => {
    const { input, btn, getByText } = renderComponent();
    const amount = '250000';
    fireEvent.change(input, { target: { value: amount } });
    fireEvent.click(btn);
    await waitForElement(() => getByText('Deposited 250,000 sats to alice'));
    expect(lightningServiceMock.getNewAddress).toBeCalledTimes(1);
    expect(bitcoindServiceMock.sendFunds).toBeCalledWith(
      expect.anything(),
      'bc1aaaa',
      0.0025,
    );
  });
github jamaljsr / polar / src / components / designer / lightning / LightningDetails.spec.tsx View on Github external
        await wait(() => fireEvent.click(getByText('REST')));
        expect(shell.openExternal).toBeCalledWith(