oxynote/web/app/utils/string.test.ts
2026-08-17 17:11:50 +02:00

35 lines
744 B
TypeScript

import { describe, it } from "vitest"
import { cleanSentenceCase } from "./string"
describe("cleanSentenceCase", () => {
it.for([
{
name: "capitalizes the first letter",
input: "hello world",
expected: "Hello world",
},
{
name: "returns an empty string unchanged",
input: "",
expected: "",
},
{
name: "keeps an already capitalized string unchanged",
input: "Hello",
expected: "Hello",
},
{
name: "capitalizes a single-character string",
input: "a",
expected: "A",
},
{
name: "leaves a non-letter first character unchanged",
input: "1st item",
expected: "1st item",
},
])("$name", ({ input, expected }, { expect }) => {
expect(cleanSentenceCase(input)).toBe(expected)
})
})