Open History to see the last commit
1import { describe, expect, it } from "vitest";
2
3import { truncate } from "./String.ts";
4
5describe("truncate", () => {
6 it("trims surrounding whitespace", () => {
7 expect(truncate(" hello world ")).toBe("hello world");
8 });
9
10 it("returns shorter strings unchanged", () => {
11 expect(truncate("alpha", 10)).toBe("alpha");
12 });
13
14 it("truncates long strings and appends an ellipsis", () => {
15 expect(truncate("abcdefghij", 5)).toBe("abcde...");
16 });
17});