hypertune
Version:
[Hypertune](https://www.hypertune.com/) is the most flexible platform for feature flags, A/B testing, analytics and app configuration. Built with full end-to-end type-safety, Git-style version control and local, synchronous, in-memory flag evaluation. Opt
54 lines (49 loc) • 1.79 kB
text/typescript
import { expect, test } from "vitest";
import toWords from "./toWords";
test.each([
["a", "a"],
["thing", "thing"],
["some_snake_case_thing", "some snake case thing"],
["Some_Caps_Snake_Case_Thing", "Some Caps Snake Case Thing"],
["SCREAMING_SNAKE_CASE_THING", "SCREAMING SNAKE CASE THING"],
["someCamelCaseThing", "some Camel Case Thing"],
["SomePascalCaseThing", "Some Pascal Case Thing"],
["some-kebab-case-thing", "some kebab case thing"],
["Some-Kebab-Case-Thing", "Some Kebab Case Thing"],
["SCREAMING-KEBAB-CASE-THING", "SCREAMING KEBAB CASE THING"],
["some spaced thing", "some spaced thing"],
["some-cursed mixOfThings_going_on", "some cursed mix Of Things going on"],
["downloadUrl", "download Url"],
["download_url", "download url"],
["download_Url", "download Url"],
["Download_Url", "Download Url"],
["downloadURL", "download URL"],
["DownloadURL", "Download URL"],
["XMLHttpRequest", "XML Http Request"],
["XmlHTTPRequest", "Xml HTTP Request"],
["someAI", "some AI"],
["SomeAI", "Some AI"],
["MP4Enabled", "MP4 Enabled"],
["mp4Enabled", "mp4 Enabled"],
["v2", "v2"],
["V2", "V2"],
["flagV2", "flag V2"],
["flag_V2", "flag V2"],
["flag_v2", "flag v2"],
["upgradeOn20230428", "upgrade On 20230428"],
["flagVersion2", "flag Version 2"],
["useHTTP2", "use HTTP2"],
["1234", "1234"],
[" spaced -_out -", "spaced out"],
])("%s -> %s", (input, expected) => {
expect(toWords(input)).toEqual(expected.split(" "));
});
test("returns empty array for empty input", () => {
expect(toWords("")).toEqual([]);
});
test("returns empty array for blank input", () => {
expect(toWords(" ")).toEqual([]);
});
test("returns empty array for spacer-only input", () => {
expect(toWords(" _ -- ")).toEqual([]);
});