Files
tailwind-ui-library/components/utils/slug-to-normal-text.test.ts
T
2026-10-01 08:02:47 +01:00

49 lines
1.5 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import twuiSlugToNormalText from "./slug-to-normal-text";
describe("twuiSlugToNormalText", () => {
test("returns empty string for undefined", () => {
expect(twuiSlugToNormalText(undefined)).toBe("");
});
test("returns empty string for empty string", () => {
expect(twuiSlugToNormalText("")).toBe("");
});
test("converts slug to normal text", () => {
expect(twuiSlugToNormalText("hello-world")).toBe("Hello World");
});
test("converts underscore slug to normal text", () => {
expect(twuiSlugToNormalText("hello_world")).toBe("Hello World");
});
test("handles single word", () => {
expect(twuiSlugToNormalText("hello")).toBe("Hello");
});
test("removes special characters", () => {
expect(twuiSlugToNormalText("hello@world")).toBe("Hello World");
});
test("handles multiple consecutive dashes", () => {
expect(twuiSlugToNormalText("hello---world")).toBe("Hello World");
});
test("converts to title case", () => {
expect(twuiSlugToNormalText("annual-dues")).toBe("Annual Dues");
});
test("handles alphanumeric slug", () => {
expect(twuiSlugToNormalText("item-123")).toBe("Item 123");
});
test("handles mixed case input", () => {
expect(twuiSlugToNormalText("Hello-World")).toBe("Hello World");
});
test("handles user type slug", () => {
expect(twuiSlugToNormalText("super_admin")).toBe("Super Admin");
});
});