test(editor): fix wrong sanitizeCaption collapse-cap comment (F3)
The comment claimed 250 groups -> 499 chars -> slice past 500; the input is 120 "a b " groups collapsing to 479 chars, under the cap with no slice. Correct the comment and assert the 479 length. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -46,10 +46,13 @@ describe("sanitizeCaption", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("collapses whitespace before applying the 500-char cap", () => {
|
it("collapses whitespace before applying the 500-char cap", () => {
|
||||||
// 250 "a b" groups => "a b a b ..." which after collapse is 499 chars,
|
// 120 "a b " groups (600 raw chars) collapse to "a b a b ..." = 479 chars
|
||||||
// adding a trailing pair pushes past 500 and gets sliced.
|
// after trimming the trailing space, which stays under the 500 cap — so only
|
||||||
|
// the collapse is exercised here, no slice. (See the dedicated >500 test
|
||||||
|
// above for the slice boundary.)
|
||||||
const input = "a b ".repeat(120); // lots of double spaces
|
const input = "a b ".repeat(120); // lots of double spaces
|
||||||
const result = sanitizeCaption(input);
|
const result = sanitizeCaption(input);
|
||||||
|
expect(result).toHaveLength(479);
|
||||||
expect(result.length).toBeLessThanOrEqual(500);
|
expect(result.length).toBeLessThanOrEqual(500);
|
||||||
expect(result).not.toMatch(/\s{2,}/);
|
expect(result).not.toMatch(/\s{2,}/);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user