import { describe, expect, test } from "bun:test"; import twuiSlugify from "./slugify"; describe("twuiSlugify", () => { test("returns empty string for undefined input", () => { expect(twuiSlugify(undefined)).toBe(""); }); test("returns empty string for empty string input", () => { expect(twuiSlugify("")).toBe(""); }); test("slugifies simple text", () => { expect(twuiSlugify("Hello World")).toBe("hello-world"); }); test("removes special characters", () => { expect(twuiSlugify("Yes!")).toBe("yes"); }); test("removes multiple special characters", () => { expect(twuiSlugify("Hello!!! World!")).toBe("hello-world"); }); test("converts to lowercase", () => { expect(twuiSlugify("UPPERCASE TEXT")).toBe("uppercase-text"); }); test("replaces multiple spaces with single divider", () => { expect(twuiSlugify("Hello World")).toBe("hello-world"); }); test("removes leading dash by default", () => { expect(twuiSlugify(" hello")).toBe("hello"); }); test("removes trailing dash by default", () => { expect(twuiSlugify("hello ")).toBe("hello"); }); test("keeps trailing dash when allowTrailingDash is true", () => { expect(twuiSlugify("hello-", "-", true)).toBe("hello-"); }); test("uses underscore divider when specified", () => { expect(twuiSlugify("Hello World", "_")).toBe("hello_world"); }); test("handles numbers", () => { expect(twuiSlugify("Item 123")).toBe("item-123"); }); test("handles mixed alphanumeric and special chars", () => { expect(twuiSlugify("Hello @World #2024!")).toBe("hello-world-2024"); }); test("replaces consecutive dashes with single dash", () => { expect(twuiSlugify("a---b")).toBe("a-b"); }); test("trims whitespace before processing", () => { expect(twuiSlugify(" hello world ")).toBe("hello-world"); }); test("handles single character input", () => { expect(twuiSlugify("a")).toBe("a"); }); test("handles number-only input", () => { expect(twuiSlugify("123")).toBe("123"); }); });