perf(test): fold ports + terminal note suites

This commit is contained in:
Peter Steinberger
2026-02-16 01:07:09 +00:00
parent 3f44ea244f
commit 5fe47e7be6
5 changed files with 68 additions and 99 deletions

View File

@@ -1,35 +0,0 @@
import { describe, expect, it } from "vitest";
import { wrapNoteMessage } from "./note.js";
describe("wrapNoteMessage", () => {
it("preserves long filesystem paths without inserting spaces/newlines", () => {
const input =
"/Users/user/Documents/Github/impact-signals-pipeline/with/really/long/segments/file.txt";
const wrapped = wrapNoteMessage(input, { maxWidth: 22, columns: 80 });
expect(wrapped).toBe(input);
});
it("preserves long urls without inserting spaces/newlines", () => {
const input =
"https://example.com/this/is/a/very/long/url/segment/that/should/not/be/split/for-copy";
const wrapped = wrapNoteMessage(input, { maxWidth: 24, columns: 80 });
expect(wrapped).toBe(input);
});
it("preserves long file-like underscore tokens for copy safety", () => {
const input = "administrators_authorized_keys_with_extra_suffix";
const wrapped = wrapNoteMessage(input, { maxWidth: 14, columns: 80 });
expect(wrapped).toBe(input);
});
it("still chunks generic long opaque tokens to avoid pathological line width", () => {
const input = "x".repeat(70);
const wrapped = wrapNoteMessage(input, { maxWidth: 20, columns: 80 });
expect(wrapped).toContain("\n");
expect(wrapped.replace(/\n/g, "")).toBe(input);
});
});

View File

@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import { visibleWidth } from "./ansi.js";
import { wrapNoteMessage } from "./note.js";
import { renderTable } from "./table.js";
describe("renderTable", () => {
@@ -130,3 +131,36 @@ describe("renderTable", () => {
expect(line2Index).toBe(line1Index + 1);
});
});
describe("wrapNoteMessage", () => {
it("preserves long filesystem paths without inserting spaces/newlines", () => {
const input =
"/Users/user/Documents/Github/impact-signals-pipeline/with/really/long/segments/file.txt";
const wrapped = wrapNoteMessage(input, { maxWidth: 22, columns: 80 });
expect(wrapped).toBe(input);
});
it("preserves long urls without inserting spaces/newlines", () => {
const input =
"https://example.com/this/is/a/very/long/url/segment/that/should/not/be/split/for-copy";
const wrapped = wrapNoteMessage(input, { maxWidth: 24, columns: 80 });
expect(wrapped).toBe(input);
});
it("preserves long file-like underscore tokens for copy safety", () => {
const input = "administrators_authorized_keys_with_extra_suffix";
const wrapped = wrapNoteMessage(input, { maxWidth: 14, columns: 80 });
expect(wrapped).toBe(input);
});
it("still chunks generic long opaque tokens to avoid pathological line width", () => {
const input = "x".repeat(70);
const wrapped = wrapNoteMessage(input, { maxWidth: 20, columns: 80 });
expect(wrapped).toContain("\n");
expect(wrapped.replace(/\n/g, "")).toBe(input);
});
});