Skip to content

Commit 5aa003f

Browse files
committed
write test for title renderashtml
1 parent 5c6728c commit 5aa003f

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Header } from "./TourTooltip";
2+
3+
describe("Header", () => {
4+
it("renders plain text title when renderAsHtml is false", () => {
5+
const el = Header({
6+
title: "<strong>Bold Text</strong>",
7+
skipLabel: "Skip",
8+
renderAsHtml: false,
9+
onSkipClick: jest.fn(),
10+
});
11+
12+
const h1 = el.querySelector("h1")!;
13+
14+
expect(h1.innerHTML).toBe(
15+
'<div class="introjs-tooltiptext">&lt;strong&gt;Bold Text&lt;/strong&gt;'
16+
);
17+
expect(h1.querySelector("strong")).toBeNull();
18+
});
19+
20+
it("renders HTML title when renderAsHtml is true", () => {
21+
const el = Header({
22+
title: "<strong>Bold Text</strong>",
23+
skipLabel: "Skip",
24+
renderAsHtml: true,
25+
onSkipClick: jest.fn(),
26+
});
27+
28+
const h1 = el.querySelector("h1")!;
29+
30+
expect(h1.innerHTML).toBe(
31+
'<div class="introjs-tooltiptext"><strong>Bold Text</strong>'
32+
);
33+
expect(h1.querySelector("strong")?.textContent).toBe("Bold Text");
34+
});
35+
});

src/packages/tour/components/TourTooltip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ const Buttons = ({
326326
);
327327
};
328328

329-
const Header = ({
329+
export const Header = ({
330330
title,
331331
skipLabel,
332332
renderAsHtml,

0 commit comments

Comments
 (0)