Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: Cursor Agent <[email protected]>
18 lines
476 B
TypeScript
18 lines
476 B
TypeScript
import { describe, expect, it } from "vite-plus/test";
|
|
|
|
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...");
|
|
});
|
|
});
|