Skip to content
This repository was archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
👷 update ConfirmationTooltip test to reflect animations being disable…
Browse files Browse the repository at this point in the history
…d for tests
  • Loading branch information
justinanastos committed Feb 7, 2020
1 parent 177e13e commit e5c2118
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/ConfirmationTooltip/ConfirmationTooltip.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,25 @@ test("when child element is clicked, the tooltip is shown", () => {
const tooltipContent = faker.lorem.word();
const interactiveElementText = faker.lorem.word();

const { container, getByText, queryByText } = render(
const { getByText, queryByText } = render(
<SpaceKitProvider disableAnimations>
<ConfirmationTooltip content={tooltipContent}>
<span>{interactiveElementText}</span>
</ConfirmationTooltip>
</SpaceKitProvider>
);

expect(queryByText(tooltipContent)).not.toBeInTheDocument();
userEvent.click(getByText(interactiveElementText));
getByText(tooltipContent);
});

test("when a tooltip is shown, it is removed after a delay", () => {
jest.useFakeTimers();
const tooltipContent = faker.lorem.word();
const interactiveElementText = faker.lorem.word();

const { getByText, queryByText } = render(
<SpaceKitProvider disableAnimations>
<ConfirmationTooltip content={tooltipContent}>
<span>{interactiveElementText}</span>
Expand All @@ -27,7 +45,5 @@ test("when child element is clicked, the tooltip is shown", () => {
getByText(tooltipContent);
jest.runTimersToTime(5000);

expect(
container.closest("body")!.querySelector(".tippy-popper")
).not.toBeVisible();
expect(queryByText(tooltipContent)).not.toBeInTheDocument();
});

0 comments on commit e5c2118

Please sign in to comment.