Skip to content

Commit 078fd46

Browse files
author
Ruben Carvalho
committed
chore: Add multi-line test
1 parent 1cdc45f commit 078fd46

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/code-view/__tests__/code-view.test.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,26 @@ describe("CodeView", () => {
1111
afterEach(() => {
1212
cleanup();
1313
});
14-
test("correctly renders component content", () => {
14+
test("correctly renders simple content", () => {
1515
render(<CodeView content={"Hello World"}></CodeView>);
1616
const wrapper = createWrapper()!.findCodeView();
1717
expect(wrapper!.findContent()[0].getElement()).toHaveTextContent("Hello World");
1818
});
1919

20+
test("correctly renders multi line content", () => {
21+
const content = `# Hello World\n\nThis is a markdown example.`;
22+
23+
render(<CodeView content={content}></CodeView>);
24+
const wrapper = createWrapper()!.findCodeView();
25+
const contentElements = wrapper!.findContent();
26+
expect(contentElements.length).toEqual(3);
27+
const renderedContent = contentElements
28+
.map((element) => element.getElement().textContent)
29+
.join("")
30+
.trim();
31+
expect(renderedContent).toBe(content);
32+
});
33+
2034
test("correctly renders copy button slot", () => {
2135
render(<CodeView content={"Hello World"} actions={<button>Copy</button>}></CodeView>);
2236
const wrapper = createWrapper()!.findCodeView();

0 commit comments

Comments
 (0)