Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

String.test.ts

17 lines465 Bytes

1import { describe, expect, it } from "vitest";
2​
3import { truncate } from "./String";
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});