From 54f6b459c117d046acae6d2ce9e898d3ca3b75fc Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Tue, 10 Dec 2024 07:53:02 +0100 Subject: [PATCH] test: adapt tooltip text checks --- src/tests/lib/components/Tooltip.spec.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/tests/lib/components/Tooltip.spec.ts b/src/tests/lib/components/Tooltip.spec.ts index dbc9cff1..8f14be1a 100644 --- a/src/tests/lib/components/Tooltip.spec.ts +++ b/src/tests/lib/components/Tooltip.spec.ts @@ -33,7 +33,7 @@ describe("Tooltip", () => { const tooltipElement = baseElement.querySelector(".tooltip"); expect(tooltipElement).toBeInTheDocument(); expect(tooltipElement?.classList).not.toContain("not-rendered"); - expect(tooltipElement?.innerHTML).toBe("text"); + expect(tooltipElement?.textContent).toBe("text"); }); it("should render tooltip slot content", () => { @@ -42,9 +42,13 @@ describe("Tooltip", () => { const tooltipElement = baseElement.querySelector(".tooltip"); expect(tooltipElement).toBeInTheDocument(); expect(tooltipElement?.classList).not.toContain("not-rendered"); - expect(tooltipElement?.innerHTML).toBe( - '
slot text
', + + const tooltipSlot = tooltipElement?.querySelector( + "[slot='tooltip-content']", ); + expect(tooltipSlot).toBeInTheDocument(); + expect(tooltipSlot?.nodeName.toLowerCase()).toEqual("div"); + expect(tooltipSlot?.textContent).toBe("slot text"); }); it("should render aria-describedby and relevant id", () => {