Elffuss BraidHub

kikocis/continue public

3a1e5cc69df2 路 1.0 KiBRawPermalink
1import { truncateToLastNBytes } from "./refreshIndex";
2
3describe("truncateToLastNBytes", () => {
4 it("should return full string if maxBytes greater than string byte length", () => {
5 const input = "Hello World";
6 const result = truncateToLastNBytes(input, 100);
7 expect(result).toBe("Hello World");
8 });
9
10 it("should truncate ASCII string correctly", () => {
11 const input = "Hello World";
12 const result = truncateToLastNBytes(input, 5);
13 expect(result).toBe("World");
14 });
15
16 it("should handle empty string", () => {
17 const input = "";
18 const result = truncateToLastNBytes(input, 5);
19 expect(result).toBe("");
20 });
21
22 it("should handle UTF-8 characters correctly", () => {
23 const input = "馃憢 Hello";
24 // 馃憢 is 4 bytes, space is 1 byte
25 const result = truncateToLastNBytes(input, 5);
26 expect(result).toBe("Hello");
27 });
28
29 it("should handle maxBytes of 0", () => {
30 const input = "Hello World";
31 const result = truncateToLastNBytes(input, 0);
32 expect(result).toBe("");
33 });
34});