Skip to content

Commit 253936d

Browse files
committed
[New] Added test cases for tooltip
1 parent d4ad0ba commit 253936d

File tree

2 files changed

+28
-33
lines changed

2 files changed

+28
-33
lines changed

Diff for: app/javascript/components/tooltip/component.spec.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { mountedComponent, screen } from "../../test-utils";
2+
3+
import Tooltip from "./component";
4+
5+
describe("components/tooltip", () => {
6+
it("renders tooltip", () => {
7+
const TooltipComponent = () => (
8+
<Tooltip title="wrapper content" data-testid="wrapper-content">
9+
<div>wrapped children</div>
10+
</Tooltip>
11+
);
12+
13+
mountedComponent(<TooltipComponent />);
14+
expect(screen.getByText(/wrapped children/i)).toBeInTheDocument();
15+
});
16+
17+
it("does not render tooltip without title", () => {
18+
const TooltipComponent = () => (
19+
<Tooltip title="">
20+
<div>wrapped children</div>
21+
</Tooltip>
22+
);
23+
24+
mountedComponent(<TooltipComponent />);
25+
expect(screen.getByText(/wrapped children/i)).toBeInTheDocument();
26+
expect(screen.queryAllByRole("tooltip")).toHaveLength(0);
27+
});
28+
});

Diff for: app/javascript/components/tooltip/component.unit.test.js

-33
This file was deleted.

0 commit comments

Comments
 (0)