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("leaves short text alone", () => {
7 expect(truncate("hello", 50)).toBe("hello");
8 });
9
10 it("cuts by Unicode code point so emoji stay whole", () => {
11 expect(truncate("👍👍👍", 5)).toBe("👍👍👍");
12 expect(truncate("👍👍👍👍", 3)).toBe("👍👍👍...");
13 });
14
15 it("trims before measuring", () => {
16 expect(truncate(" hello ", 5)).toBe("hello");
17 });
18});