it("keeps leading whitespace when splitting long lines", () => { const text = " indented line with words that force splits"; const chunks = chunkDiscordText(text, { maxChars: 14, maxLines: 50 });
expect(chunks.length).toBeGreaterThan(1);
expect(chunks.join("")).toBe(text);
});
it("keeps reasoning italics balanced across chunks", () => { const body = Array.from({ length: 25 }, (_, i) => `${i + 1}. line`).join("\n"); const text = `Reasoning:\n_${body}_`;
for (const chunk of chunks) { // Each chunk should have balanced italics markers (even count). const count = (chunk.match(/_/g) || []).length;
expect(count % 2).toBe(0);
}
// Ensure italics reopen on subsequent chunks
expect(chunks[0]).toContain("_1. line"); // Second chunk should reopen italics at the start
expect(chunks[1].trimStart().startsWith("_")).toBe(true);
});
it("keeps reasoning italics balanced when chunks split by char limit", () => { const longLine = "This is a very long reasoning line that forces char splits."; const body = Array.from({ length: 5 }, () => longLine).join("\n"); const text = `Reasoning:\n_${body}_`;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.