Skip to content

Commit 2b21335

Browse files
committed
fix: Handle undefined content
1 parent f3e1063 commit 2b21335

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,10 @@ describe("CodeView", () => {
103103
const element = wrapper!.findContent().getElement();
104104
expect(element.outerHTML).toContain("code-line-wrap");
105105
});
106+
107+
test("handles undefined content", () => {
108+
render(<CodeView content={undefined}></CodeView>);
109+
const wrapper = createWrapper().findCodeView()!;
110+
expect(wrapper!.findContent().getElement().textContent).toBe("\n");
111+
});
106112
});

src/code-view/internal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const textHighlight = (code: string) => {
3232
};
3333

3434
export function InternalCodeView({
35-
content,
35+
content = "",
3636
actions,
3737
lineNumbers,
3838
wrapLines,

0 commit comments

Comments
 (0)