Skip to content

Commit

Permalink
test: fix ui tests
Browse files Browse the repository at this point in the history
Signed-off-by: Zxilly <[email protected]>
  • Loading branch information
Zxilly committed Jul 7, 2024
1 parent 5a770a6 commit 029a047
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ui/src/Tooltip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ function getTestNode(): Entry {
it("tooltip should render correctly when visible", () => {
const { getByText } = render(
<Tooltip
x={0}
y={0}
visible
node={getTestNode()}
/>,
Expand All @@ -43,10 +45,27 @@ it("tooltip should render correctly when visible", () => {
it("tooltip should not render when not visible", () => {
const r = render(
<Tooltip
x={0}
y={0}
visible={false}
node={getTestNode()}
/>,
);
// should have a tooltip-hidden class
expect(r.container.querySelector(".tooltip-hidden")).not.toBeNull();
});

it("tooltip should respond to position", () => {
const r = render(
<Tooltip
x={0}
y={0}
visible
node={getTestNode()}
/>,
);
const tooltip = r.container.querySelector<HTMLElement>(".tooltip");
expect(tooltip).not.toBeNull();
expect(tooltip!.style.left).toBe("10px");
expect(tooltip!.style.top).toBe("30px");
});

0 comments on commit 029a047

Please sign in to comment.