Skip to content

Instantly share code, notes, and snippets.

@SatyaAchanta
Created December 25, 2022 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SatyaAchanta/cd1163ef0f4146450a293df296fda140 to your computer and use it in GitHub Desktop.
Save SatyaAchanta/cd1163ef0f4146450a293df296fda140 to your computer and use it in GitHub Desktop.
pop over test
test("should display popover message when hovered", async () => {
const user = userEvent.setup();
render(<SummaryForm />);
//popover should start hidden
const noPopoverElement = screen.queryByText(
/no ice cream will actually be delivered/i
);
expect(noPopoverElement).not.toBeInTheDocument();
// popover should display on hover
const checkboxElement = screen.getByText(/terms and conditions/i);
await user.hover(checkboxElement);
const popoverElement = screen.getByText(
/no ice cream will actually be delivered/i
);
expect(popoverElement).toBeInTheDocument();
// popover should be hidden on unhover
await user.unhover(checkboxElement);
expect(noPopoverElement).not.toBeInTheDocument();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment