Changesets · Branches · Tags · Compare
| Changeset | c33d3f5d8d051b5b37eb844748e4b2ada40bd7aeb7693e8801d695d027fcd41a |
|---|---|
| Author | uinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-17 15:24 +05:30 |
| Committer | uinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-17 15:24 +05:30 |
| Parents | 7bbe94906926 |
1 file changed
modified gui/src/util/clientTools/findAndReplaceUtils.test.ts +21 −0
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | EMPTY_NON_FIRST_EDIT_MESSAGE, |
| 5 | 5 | FOUND_MULTIPLE_FIND_STRINGS_ERROR, |
| 6 | 6 | performFindAndReplace, |
| 7 | + trimEmptyLines, | |
| 7 | 8 | validateCreatingForMultiEdit, |
| 8 | 9 | validateSingleEdit, |
| 9 | 10 | } from "./findAndReplaceUtils"; |
| @@ -454,3 +455,23 @@ | ||
| 454 | 455 | }); |
| 455 | 456 | }); |
| 456 | 457 | }); |
| 458 | + | |
| 459 | +describe("trimEmptyLines", () => { | |
| 460 | + it("trims leading empty lines from start", () => { | |
| 461 | + const input = ["", "", "a", "", "b"]; | |
| 462 | + const result = trimEmptyLines({ lines: input, fromEnd: false }); | |
| 463 | + expect(result).toEqual(["a", "", "b"]); | |
| 464 | + }); | |
| 465 | + | |
| 466 | + it("trims trailing empty lines from end", () => { | |
| 467 | + const input = ["a", "", "b", "", ""]; | |
| 468 | + const result = trimEmptyLines({ lines: input, fromEnd: true }); | |
| 469 | + expect(result).toEqual(["a", "", "b"]); | |
| 470 | + }); | |
| 471 | + | |
| 472 | + it("returns empty array when all lines are empty", () => { | |
| 473 | + const input = ["", "", ""]; | |
| 474 | + const result = trimEmptyLines({ lines: input, fromEnd: false }); | |
| 475 | + expect(result).toEqual([]); | |
| 476 | + }); | |
| 477 | +}); |