|
3 | 3 | * Covers strict env parsing and compact session labels. |
4 | 4 | */ |
5 | 5 | import { afterEach, describe, expect, it, vi } from "vitest"; |
6 | | -import { deriveSessionName, readEnvInt } from "./bash-tools.shared.js"; |
| 6 | +import { chunkString, deriveSessionName, readEnvInt } from "./bash-tools.shared.js"; |
7 | 7 |
|
8 | 8 | describe("readEnvInt", () => { |
9 | 9 | afterEach(() => { |
@@ -70,3 +70,22 @@ describe("deriveSessionName", () => { |
70 | 70 | } |
71 | 71 | }); |
72 | 72 | }); |
| 73 | + |
| 74 | +describe("chunkString", () => { |
| 75 | + it("preserves surrogate pairs at chunk boundaries", () => { |
| 76 | + const input = "a".repeat(8191) + "🚀b"; |
| 77 | + expect(chunkString(input, 8192)).toEqual(["a".repeat(8191), "🚀b"]); |
| 78 | + }); |
| 79 | + |
| 80 | + it("returns single chunk for input smaller than limit", () => { |
| 81 | + expect(chunkString("hello", 8192)).toEqual(["hello"]); |
| 82 | + }); |
| 83 | + |
| 84 | + it("emits a whole code point when the limit is one UTF-16 unit", () => { |
| 85 | + expect(chunkString("😀a", 1)).toEqual(["😀", "a"]); |
| 86 | + }); |
| 87 | + |
| 88 | + it("preserves every code point across mixed chunk boundaries", () => { |
| 89 | + expect(chunkString("aa🚀bb", 2)).toEqual(["aa", "🚀", "bb"]); |
| 90 | + }); |
| 91 | +}); |
0 commit comments