1import { describe, expect, it } from "vite-plus/test";
2β
3import { truncate } from "./String.ts";
4β
5describe("truncate", () => {
6 it("cuts by Unicode code point so emoji stay whole", () => {
7 expect(truncate("πππ", 5)).toBe("πππ");
8 expect(truncate("ππππ", 3)).toBe("πππ...");
9 });
10β
11 it("trims before measuring", () => {
12 expect(truncate(" hello ", 5)).toBe("hello");
13 });
14});