mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
test(text): move case tests to separate files (#5807)
This commit is contained in:
parent
c8fe63417a
commit
531145a08b
@ -1,157 +0,0 @@
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { assertEquals } from "@std/assert";
|
||||
import {
|
||||
toCamelCase,
|
||||
toConstantCase,
|
||||
toKebabCase,
|
||||
toPascalCase,
|
||||
toSnakeCase,
|
||||
} from "./mod.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("toPascalCase() converts a single word with Cyrillic letters", () => {
|
||||
const input = "шруберри";
|
||||
const expected = "Шруберри";
|
||||
assertEquals(toPascalCase(input), 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);
|
||||
});
|
||||
|
||||
Deno.test("toSnakeCase() splits words before and after the numbers", () => {
|
||||
assertEquals(toSnakeCase("str2Num"), "str_2_num");
|
||||
assertEquals(toSnakeCase("Str2Num"), "str_2_num");
|
||||
});
|
||||
|
||||
Deno.test("toConstantCase() converts a single word", () => {
|
||||
const input = "shruberry";
|
||||
const expected = "SHRUBERRY";
|
||||
assertEquals(toConstantCase(input), expected);
|
||||
});
|
||||
|
||||
Deno.test("toConstantCase() converts a sentence", () => {
|
||||
const input = "she turned me into a newt";
|
||||
const expected = "SHE_TURNED_ME_INTO_A_NEWT";
|
||||
assertEquals(toConstantCase(input), expected);
|
||||
});
|
||||
|
||||
Deno.test("toConstantCase() converts multiple delimiters", () => {
|
||||
const result = toConstantCase("I am up-to-date!");
|
||||
const expected = "I_AM_UP_TO_DATE";
|
||||
assertEquals(result, expected);
|
||||
});
|
||||
|
||||
Deno.test("toConstantCase() trims whitespace", () => {
|
||||
const result = toConstantCase(" deno Is AWESOME ");
|
||||
const expected = "DENO_IS_AWESOME";
|
||||
assertEquals(result, expected);
|
||||
});
|
32
text/to_camel_case_test.ts
Normal file
32
text/to_camel_case_test.ts
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { assertEquals } from "@std/assert";
|
||||
import { toCamelCase } from "./mod.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);
|
||||
});
|
28
text/to_constant_case_test.ts
Normal file
28
text/to_constant_case_test.ts
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { assertEquals } from "@std/assert";
|
||||
import { toConstantCase } from "./mod.ts";
|
||||
|
||||
Deno.test("toConstantCase() converts a single word", () => {
|
||||
const input = "shruberry";
|
||||
const expected = "SHRUBERRY";
|
||||
assertEquals(toConstantCase(input), expected);
|
||||
});
|
||||
|
||||
Deno.test("toConstantCase() converts a sentence", () => {
|
||||
const input = "she turned me into a newt";
|
||||
const expected = "SHE_TURNED_ME_INTO_A_NEWT";
|
||||
assertEquals(toConstantCase(input), expected);
|
||||
});
|
||||
|
||||
Deno.test("toConstantCase() converts multiple delimiters", () => {
|
||||
const result = toConstantCase("I am up-to-date!");
|
||||
const expected = "I_AM_UP_TO_DATE";
|
||||
assertEquals(result, expected);
|
||||
});
|
||||
|
||||
Deno.test("toConstantCase() trims whitespace", () => {
|
||||
const result = toConstantCase(" deno Is AWESOME ");
|
||||
const expected = "DENO_IS_AWESOME";
|
||||
assertEquals(result, expected);
|
||||
});
|
32
text/to_kebab_case_test.ts
Normal file
32
text/to_kebab_case_test.ts
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { assertEquals } from "@std/assert";
|
||||
import { toKebabCase } from "./mod.ts";
|
||||
|
||||
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);
|
||||
});
|
38
text/to_pascal_case_test.ts
Normal file
38
text/to_pascal_case_test.ts
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { assertEquals } from "@std/assert";
|
||||
import { toPascalCase } from "./mod.ts";
|
||||
|
||||
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("toPascalCase() converts a single word with Cyrillic letters", () => {
|
||||
const input = "шруберри";
|
||||
const expected = "Шруберри";
|
||||
assertEquals(toPascalCase(input), expected);
|
||||
});
|
37
text/to_snake_case_test.ts
Normal file
37
text/to_snake_case_test.ts
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { assertEquals } from "@std/assert";
|
||||
import { toSnakeCase } from "./mod.ts";
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
Deno.test("toSnakeCase() splits words before and after the numbers", () => {
|
||||
assertEquals(toSnakeCase("str2Num"), "str_2_num");
|
||||
assertEquals(toSnakeCase("Str2Num"), "str_2_num");
|
||||
});
|
Loading…
Reference in New Issue
Block a user