Sha256: 8205fdf4f976f69945e00fac1e8b73ca0f9caa0b22a25024f6a8e307c9a8a08e

Contents?: true

Size: 1.23 KB

Versions: 53

Compression:

Stored size: 1.23 KB

Contents

import React from "react";
import { cleanup, render, screen, fireEvent, waitFor } from "../utilities/test-utils";
import { Button, Tooltip } from "..";

function TooltipTest() {
  const text = "this is a text",
    placement = "top",
    triggerText = "hover me",
    zIndex = "10";

  return (
    <Tooltip
        data={{ testid: "primary-test" }}
        placement={placement}
        text={text}
        zIndex={zIndex}
    >
      <Button text={triggerText} />
    </Tooltip>
  );
}

test("renders the component", () => {
  render(<TooltipTest />);

  const kit = screen.getByTestId("primary-test");
  expect(kit).toBeInTheDocument();
  expect(kit).toHaveClass("pb_tooltip_kit");

  cleanup();
});

test("opens on mouseenter", async () => {
  render(<TooltipTest />);

  fireEvent.mouseEnter(screen.getByRole("tooltip_trigger"));
  await waitFor(() => {
    expect(screen.queryByRole("tooltip")).toBeInTheDocument();
    cleanup();
  })
});

test("closes on mouseleave", async () => {
  render(<TooltipTest />);

  fireEvent.mouseEnter(screen.getByRole("tooltip_trigger"));
  fireEvent.mouseLeave(screen.getByRole("tooltip_trigger"));

  await waitFor(() => {
    expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
    cleanup();
  })
});

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
playbook_ui-12.1.0 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-12.0.0 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.20.0.pre.alpha.passthrough1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.20.0.pre.alpha.railsdialog1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.20.0.pre.alpha.focus1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.20.0 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.19.0.pre.alpha.map1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.19.0.pre.alpha.pagpassthrough1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.19.0 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.18.0.pre.alpha.pagutility1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.19.0.pre.typeahead1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.18.0 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.17.0 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.15.0.pre.alpha.dependencies1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.16.0.pre.alpha.paginationrails1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.16.0 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.16.0.pre.alpha.reactupgrade1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.15.0.pre.alpha.table1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.16.0.pre.alpha.pagination.rails1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.15.0 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx