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-11.8.0 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.7.0.pre.alpha.table1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.7.0 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.6.0.pre.alpha.fontawesome app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.5.0.pre.alpha.fontawesome app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.7.0.pre.alpha.pre.guagechart1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.6.0 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.5.0.pre.alpha.datepicker1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.6.0.pre.alpha.rubocopperf1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.6.1.pre.alpha.rubocop.pre.performance1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.5.0.pre.alpha.pre.rubocop app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.6.0.pre.alpha.momenttz1 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx
playbook_ui-11.5.0 app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx