How to use the react-testing-library.Simulate.click 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 c8r / kit / core / __tests__ / State.js View on Github external
test('State maintains a state context that can be updated', () => {
  const { getByText, getByTestId } = render()
  const incrementButton = getByText('+')
  const decrementButton = getByText('-')

  Simulate.click(incrementButton)
  Simulate.click(incrementButton)
  expect(getByTestId('count').textContent).toBe('2')

  Simulate.click(decrementButton)
  expect(getByTestId('count').textContent).toBe('1')
})
github c8r / kit / core / __tests__ / State.js View on Github external
test('State maintains a state context that can be updated', () => {
  const { getByText, getByTestId } = render()
  const incrementButton = getByText('+')
  const decrementButton = getByText('-')

  Simulate.click(incrementButton)
  Simulate.click(incrementButton)
  expect(getByTestId('count').textContent).toBe('2')

  Simulate.click(decrementButton)
  expect(getByTestId('count').textContent).toBe('1')
})
github ticketmaster / aurora / src / components / Input / __tests__ / QtySelector.spec.js View on Github external
it("decrements from non-zero value correctly", () => {
    const { container } = renderQtySelectorComponent();
    const decButton = container.getElementsByTagName("button")[0];
    const incButton = container.getElementsByTagName("button")[1];

    Simulate.click(incButton);
    Simulate.click(incButton);
    Simulate.click(decButton);
    Simulate.click(decButton);

    expect(container.firstChild).toMatchSnapshot();
  });
github ticketmaster / aurora / src / components / Link / __tests__ / List.spec.js View on Github external
it("onItemClick in LinkList is called when a list item is clicked", () => {
    const onOptionSelected = mockFn;
    const { container } = render(
      
        {countries.map((option, index) => (
          
            {option.text}
          
        ))}
      
    );

    Simulate.click(container.querySelector(".links__list__item"));
    expect(onOptionSelected).toHaveBeenCalled();
  });
github ticketmaster / aurora / src / components / Link / __tests__ / Item.spec.js View on Github external
it("toggles onClick", () => {
    const { container } = getContainer();
    const linkItem = container.querySelector(".list-container");

    Simulate.click(linkItem);
    expect(linkItem.classList.contains("list-container--open")).toEqual(true);

    Simulate.click(linkItem);
    expect(linkItem.classList.contains("list-container--closed")).toEqual(true);
  });
github ticketmaster / aurora / src / components / Button / __tests__ / RatingBadge.spec.js View on Github external
it("should invoke an onClick handler when passed", () => {
    const onClick = jest.fn();
    const { getByText } = render(
      
        RatingBadge
      
    );

    Simulate.click(getByText("RatingBadge"));
    expect(onClick).toHaveBeenCalled();
  });
});
github ticketmaster / aurora / src / components / Button / __tests__ / Base.spec.js View on Github external
it("should invoke an onClick handler when passed", () => {
    const onClick = jest.fn();
    const { getByText } = render(
      <button>
        Dummy Label
      </button>
    );

    Simulate.click(getByText("Dummy Label"));
    expect(onClick).toHaveBeenCalled();
  });
});
github ticketmaster / aurora / src / components / List / __tests__ / SectionItem.spec.js View on Github external
it("renders SectionItem with children correctly", () =&gt; {
    const { container } = render(
       {}} onModalClose={() =&gt; {}}&gt;
        
          <div>Asia</div>
          <div>Africa</div>
          <div>North America</div>
        
      
    );
    Simulate.click(container.querySelector(".section-item"));
    expect(container.firstChild).toMatchSnapshot();
  });
});
github ticketmaster / aurora / src / components / Input / __tests__ / QtySelector.spec.js View on Github external
it("increments twice correctly", () => {
    const { container } = renderQtySelectorComponent();
    const button = container.getElementsByTagName("button")[1];

    Simulate.click(button);
    Simulate.click(button);

    expect(container.firstChild).toMatchSnapshot();
  });
github ticketmaster / aurora / src / components / Drawer / __tests__ / Provider.spec.js View on Github external
onClick={() =&gt; {
                  setContent(
                    <div data-testid="drawer-content">Drawer Content</div>
                  );
                }}
              &gt;
                ClickMe!
              
            )}
          
          Content
        
      
    );

    Simulate.click(getByTestId("button"));

    expect(container).toMatchSnapshot();
  });