Files
t3code/packages/shared/src/String.test.ts

18 lines
468 B
TypeScript

import { describe, expect, it } from "vitest";
import { truncate } from "./String.ts";
describe("truncate", () => {
it("trims surrounding whitespace", () => {
expect(truncate(" hello world ")).toBe("hello world");
});
it("returns shorter strings unchanged", () => {
expect(truncate("alpha", 10)).toBe("alpha");
});
it("truncates long strings and appends an ellipsis", () => {
expect(truncate("abcdefghij", 5)).toBe("abcde...");
});
});