Files
tailwind-ui-library/components/utils/lower-to-title-case.test.ts
T
2026-10-01 08:02:47 +01:00

43 lines
1.4 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import lowerToTitleCase from "./lower-to-title-case";
describe("lowerToTitleCase", () => {
test("converts snake_case to Title Case", () => {
expect(lowerToTitleCase("hello_world")).toBe("Hello World");
});
test("converts kebab-case to Title Case", () => {
expect(lowerToTitleCase("hello-world")).toBe("Hello World");
});
test("converts mixed snake-kebab", () => {
expect(lowerToTitleCase("hello_world-test")).toBe("Hello World Test");
});
test("handles single word", () => {
expect(lowerToTitleCase("hello")).toBe("Hello");
});
test("handles already title case", () => {
expect(lowerToTitleCase("Hello")).toBe("Hello");
});
test("handles empty string", () => {
expect(lowerToTitleCase("")).toBe("");
});
test("handles all uppercase input", () => {
expect(lowerToTitleCase("HELLO_WORLD")).toBe("Hello World");
});
test("handles mixed case input", () => {
expect(lowerToTitleCase("hello_World")).toBe("Hello World");
});
test("converts user type values correctly", () => {
expect(lowerToTitleCase("super_admin")).toBe("Super Admin");
expect(lowerToTitleCase("financial_secretary")).toBe("Financial Secretary");
expect(lowerToTitleCase("primary_resident")).toBe("Primary Resident");
});
});