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

truncateTitle.test.ts

17 lines506 Bytes

1import { describe, expect, it } from "vitest";
2​
3import { truncateTitle } from "./truncateTitle";
4​
5describe("truncateTitle", () => {
6 it("trims surrounding whitespace", () => {
7 expect(truncateTitle(" hello world ")).toBe("hello world");
8 });
9​
10 it("returns trimmed text when within max length", () => {
11 expect(truncateTitle("alpha", 10)).toBe("alpha");
12 });
13​
14 it("appends ellipsis when text exceeds max length", () => {
15 expect(truncateTitle("abcdefghij", 5)).toBe("abcde...");
16 });
17});