Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyab committed Sep 11, 2024
1 parent 3f7dc2a commit 548f2ca
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/unit/strip-trailing-hardline.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fill, hardline } from "../../src/document/builders.js";
import { fill, hardline, line } from "../../src/document/builders.js";
import { stripTrailingHardline } from "../../src/document/utils.js";

test("Should not mutate doc", () => {
Expand All @@ -18,3 +18,29 @@ test("Should not mutate doc", () => {
test("Should work for strings", () => {
expect(stripTrailingHardline("\ntext\n\n\r\r\r\n\r\n")).toBe("\ntext");
});

test("Should work for fill()", () => {
expect(stripTrailingHardline(fill(["text", hardline, "\n"]))).toStrictEqual(
fill(["text"]),
);

expect(
stripTrailingHardline(
fill([
"text",
line,
"text",
line,
"\n",
hardline,
"\n\n",
[hardline, hardline, hardline],
"",
hardline,
[],
hardline,
"\n",
]),
),
).toStrictEqual(fill(["text", line, "text", line, ""]));
});

0 comments on commit 548f2ca

Please sign in to comment.