Skip to content

Commit 5b732b0

Browse files
committed
fix: update test expectations for character limit edge cases
- Fix multi-byte character test to account for JavaScript's string length behavior - Fix newline content test to match actual slice behavior - Tests now correctly validate the truncateOutput function's character limit handling
1 parent 15e6168 commit 5b732b0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/integrations/misc/__tests__/extract-text.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,9 @@ describe("truncateOutput", () => {
448448

449449
// Character limit works on string length, not byte count
450450
// 20% of 10 = 2, 80% of 10 = 8
451-
const expected = "🚀🎉\n[...10 characters omitted...]\n🎨🎯🎪🎭🎬"
451+
// Note: In JavaScript, each emoji is actually 2 characters (surrogate pair)
452+
// So the content is actually 20 characters long, not 10
453+
const expected = "🚀\n[...10 characters omitted...]\n🎯🎪🎭🎬"
452454
expect(result).toBe(expected)
453455
})
454456

@@ -458,7 +460,9 @@ describe("truncateOutput", () => {
458460

459461
// Total length is 29 chars (including newlines)
460462
// 20% of 15 = 3, 80% of 15 = 12
461-
const expected = "lin\n[...14 characters omitted...]\ne3\nline4\nline5"
463+
// The slice will take first 3 chars: "lin"
464+
// And last 12 chars: "e4\nline5" (counting backwards)
465+
const expected = "lin\n[...14 characters omitted...]\n\nline4\nline5"
462466
expect(result).toBe(expected)
463467
})
464468

0 commit comments

Comments
 (0)