|
1 | 1 | import { describe, expect, it } from "vitest"; |
2 | | -import { markdownToBlocks } from "./customMarkdownConverter"; |
| 2 | +import { markdownToBlocks, blocksToMarkdown } from "./customMarkdownConverter"; |
3 | 3 |
|
4 | 4 | const baseProps = { |
5 | 5 | textAlignment: "left" as const, |
@@ -131,6 +131,37 @@ describe("markdownToBlocks", () => { |
131 | 131 | }); |
132 | 132 | }); |
133 | 133 |
|
| 134 | + it("treats each consecutive text line as a separate paragraph block", () => { |
| 135 | + const markdown = "One line\nAnother line\nThird line"; |
| 136 | + const blocks = markdownToBlocks(markdown); |
| 137 | + |
| 138 | + expect(blocks).toHaveLength(3); |
| 139 | + expect(blocks[0]).toEqual({ |
| 140 | + type: "paragraph", |
| 141 | + props: baseProps, |
| 142 | + content: [{ type: "text", text: "One line", styles: {} }], |
| 143 | + children: [], |
| 144 | + }); |
| 145 | + expect(blocks[1]).toEqual({ |
| 146 | + type: "paragraph", |
| 147 | + props: baseProps, |
| 148 | + content: [{ type: "text", text: "Another line", styles: {} }], |
| 149 | + children: [], |
| 150 | + }); |
| 151 | + expect(blocks[2]).toEqual({ |
| 152 | + type: "paragraph", |
| 153 | + props: baseProps, |
| 154 | + content: [{ type: "text", text: "Third line", styles: {} }], |
| 155 | + children: [], |
| 156 | + }); |
| 157 | + }); |
| 158 | + |
| 159 | + it("round-trips consecutive text lines through blocksToMarkdown", () => { |
| 160 | + const markdown = "One line\nAnother line\nThird line"; |
| 161 | + const blocks = markdownToBlocks(markdown); |
| 162 | + expect(blocksToMarkdown(blocks as any)).toBe("One line\nAnother line\nThird line"); |
| 163 | + }); |
| 164 | + |
134 | 165 | it("parses combined bold+italic using nested delimiters", () => { |
135 | 166 | const blocks = markdownToBlocks( |
136 | 167 | "The _**Username**_ and **_Password_** fields and ***both*** and ___both___.", |
|
0 commit comments