@bigbinary/neetoui 3.2.76 → 3.2.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/layouts.js +1 -1
- package/package.json +1 -1
- package/tests/Tooltip.test.js +44 -0
package/package.json
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Tooltip, Typography } from "../lib/components";
|
|
3
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
|
+
|
|
6
|
+
describe("Tooltip", () => {
|
|
7
|
+
it("should render on hover ", () => {
|
|
8
|
+
render(
|
|
9
|
+
<Tooltip content="Tooltip">
|
|
10
|
+
<Typography>Text</Typography>
|
|
11
|
+
</Tooltip>
|
|
12
|
+
);
|
|
13
|
+
const text = screen.getByText("Text")
|
|
14
|
+
userEvent.hover(text)
|
|
15
|
+
const tooltip = screen.getByText("Tooltip")
|
|
16
|
+
expect(tooltip).toBeInTheDocument();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should not render when user stops hovering", async () => {
|
|
20
|
+
render(
|
|
21
|
+
<Tooltip content="Tooltip" >
|
|
22
|
+
<Typography>Text</Typography>
|
|
23
|
+
</Tooltip>
|
|
24
|
+
);
|
|
25
|
+
const text = screen.getByText("Text")
|
|
26
|
+
userEvent.hover(text)
|
|
27
|
+
const tooltip = screen.getByText("Tooltip")
|
|
28
|
+
userEvent.unhover(text)
|
|
29
|
+
await waitFor(() => expect(tooltip).not.toBeVisible())
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("should auto hide tooltip after n milliseconds", async () => {
|
|
33
|
+
render(
|
|
34
|
+
<Tooltip content="Tooltip" hideAfter={100}>
|
|
35
|
+
<Typography>Text</Typography>
|
|
36
|
+
</Tooltip>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const text = screen.getByText("Text")
|
|
40
|
+
userEvent.hover(text)
|
|
41
|
+
const tooltip = screen.getByText("Tooltip")
|
|
42
|
+
await waitFor(() => expect(tooltip).not.toBeVisible())
|
|
43
|
+
});
|
|
44
|
+
});
|