Open History to see the last commit
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β
15 it("drops whitespace at the cut before the ellipsis", () => {
16 expect(truncate("hello world", 6)).toBe("hello...");
17 });
18});