Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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')
})
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')
})
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();
});
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();
});
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);
});
it("should invoke an onClick handler when passed", () => {
const onClick = jest.fn();
const { getByText } = render(
RatingBadge
);
Simulate.click(getByText("RatingBadge"));
expect(onClick).toHaveBeenCalled();
});
});
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();
});
});
it("renders SectionItem with children correctly", () => {
const { container } = render(
{}} onModalClose={() => {}}>
<div>Asia</div>
<div>Africa</div>
<div>North America</div>
);
Simulate.click(container.querySelector(".section-item"));
expect(container.firstChild).toMatchSnapshot();
});
});
it("increments twice correctly", () => {
const { container } = renderQtySelectorComponent();
const button = container.getElementsByTagName("button")[1];
Simulate.click(button);
Simulate.click(button);
expect(container.firstChild).toMatchSnapshot();
});
onClick={() => {
setContent(
<div data-testid="drawer-content">Drawer Content</div>
);
}}
>
ClickMe!
)}
Content
);
Simulate.click(getByTestId("button"));
expect(container).toMatchSnapshot();
});