deno.land / std@0.224.0 / text / case_test.ts
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "../assert/assert_equals.ts";import { toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./case.ts";
Deno.test("toCamelCase() handles an empty string", () => { assertEquals(toCamelCase(""), "");});
Deno.test("toCamelCase() converts a single word", () => { const input = "shruberry"; const expected = "shruberry"; assertEquals(toCamelCase(input), expected);});
Deno.test("toCamelCase() converts a sentence", () => { const input = "she turned me into a newt"; const expected = "sheTurnedMeIntoANewt"; assertEquals(toCamelCase(input), expected);});
Deno.test("toCamelCase() converts multiple delimiters", () => { const result = toCamelCase("I am up-to-date!"); const expected = "iAmUpToDate"; assertEquals(result, expected);});
Deno.test("toCamelCase() trims whitespace", () => { const result = toCamelCase(" deno Is AWESOME "); const expected = "denoIsAwesome"; assertEquals(result, expected);});
Deno.test("toKebabCase() handles an empty string", () => { assertEquals(toKebabCase(""), "");});
Deno.test("toKebabCase() converts a single word", () => { const input = "shruberry"; const expected = "shruberry"; assertEquals(toKebabCase(input), expected);});
Deno.test("toKebabCase() converts a sentence", () => { const input = "she turned me into a newt"; const expected = "she-turned-me-into-a-newt"; assertEquals(toKebabCase(input), expected);});
Deno.test("toKebabCase() converts multiple delimiters", () => { const result = toKebabCase("I am up-to-date!"); const expected = "i-am-up-to-date"; assertEquals(result, expected);});
Deno.test("toKebabCase() trims whitespace", () => { const result = toKebabCase(" deno Is AWESOME "); const expected = "deno-is-awesome"; assertEquals(result, expected);});
Deno.test("toPascalCase() handles empty string", () => { assertEquals(toPascalCase(""), "");});
Deno.test("toPascalCase() converts a single word", () => { const input = "shruberry"; const expected = "Shruberry"; assertEquals(toPascalCase(input), expected);});
Deno.test("toPascalCase() converts a sentence", () => { const input = "she turned me into a newt"; const expected = "SheTurnedMeIntoANewt"; assertEquals(toPascalCase(input), expected);});
Deno.test("toPascalCase() converts multiple delimiters", () => { const result = toPascalCase("I am up-to-date!"); const expected = "IAmUpToDate"; assertEquals(result, expected);});
Deno.test("toPascalCase() trims whitespace", () => { const result = toPascalCase(" deno Is AWESOME "); const expected = "DenoIsAwesome"; assertEquals(result, expected);});
Deno.test("toSnakeCase() handles an empty string", () => { assertEquals(toSnakeCase(""), "");});
Deno.test("toSnakeCase() converts a single word", () => { const input = "shruberry"; const expected = "shruberry"; assertEquals(toSnakeCase(input), expected);});
Deno.test("toSnakeCase() converts a sentence", () => { const input = "she turned me into a newt"; const expected = "she_turned_me_into_a_newt"; assertEquals(toSnakeCase(input), expected);});
Deno.test("toSnakeCase() converts multiple delimiters", () => { const result = toSnakeCase("I am up-to-date!"); const expected = "i_am_up_to_date"; assertEquals(result, expected);});
Deno.test("toSnakeCase() trims whitespace", () => { const result = toSnakeCase(" deno Is AWESOME "); const expected = "deno_is_awesome"; assertEquals(result, expected);});
Version Info