|
7 | 7 | sortTypes,
|
8 | 8 | TransformState,
|
9 | 9 | toCapitalized,
|
| 10 | + toCamelCase, |
| 11 | + toDelimiter, |
10 | 12 | } from "./transform";
|
11 | 13 |
|
12 | 14 | describe("Widget transformation", () => {
|
@@ -661,10 +663,10 @@ describe("Widget transformation", () => {
|
661 | 663 | { prefix: "parent", label: true },
|
662 | 664 | ),
|
663 | 665 | ).toEqual([
|
664 |
| - ["list: (parent_my_list_typeOne | parent_my_list_type_two)[];"], |
| 666 | + ["list: (parent_myList_typeOne | parent_myList_typeTwo)[];"], |
665 | 667 | [
|
666 |
| - `interface parent_my_list_typeOne { __typename: "type_one"; key: string; }`, |
667 |
| - `interface parent_my_list_type_two { __typename: "two"; id: number; }`, |
| 668 | + `interface parent_myList_typeOne { __typename: "type_one"; key: string; }`, |
| 669 | + `interface parent_myList_typeTwo { __typename: "two"; id: number; }`, |
668 | 670 | ],
|
669 | 671 | ]);
|
670 | 672 | });
|
@@ -723,24 +725,23 @@ describe("Pull typename", () => {
|
723 | 725 | });
|
724 | 726 | });
|
725 | 727 |
|
726 |
| -describe("Capitalization", () => { |
727 |
| - it("should capitalize words separated by spaces", () => { |
728 |
| - const str = "space separated string"; |
729 |
| - expect(toCapitalized(str)).toBe("Space Separated String"); |
730 |
| - }); |
731 |
| - |
732 |
| - it("should capitalize words separated by dashes", () => { |
733 |
| - const str = "dash-separated-string"; |
734 |
| - expect(toCapitalized(str)).toBe("Dash-Separated-String"); |
| 728 | +describe("toCamelCase", () => { |
| 729 | + it("should camelCase words separated by any non-alphanumeric characters", () => { |
| 730 | + const str = "this is a_string.with!non-alphanumeric#delimiters"; |
| 731 | + expect(toCamelCase(str)).toBe("thisIsAStringWithNonAlphanumericDelimiters"); |
735 | 732 | });
|
| 733 | +}); |
736 | 734 |
|
737 |
| - it("should capitalize words separated by underscores", () => { |
738 |
| - const str = "underscore_separated_string"; |
739 |
| - expect(toCapitalized(str)).toBe("Underscore_Separated_String"); |
| 735 | +describe("toCapitalized", () => { |
| 736 | + it("should capitalize words separated by any non-alphanumeric characters", () => { |
| 737 | + const str = "this is a_string.with!non-alphanumeric#delimiters"; |
| 738 | + expect(toCapitalized(str)).toBe("This Is A_String.With!Non-Alphanumeric#Delimiters"); |
740 | 739 | });
|
| 740 | +}); |
741 | 741 |
|
742 |
| - it("should handle mixed separators", () => { |
743 |
| - const str = "string with-mixed_separators"; |
744 |
| - expect(toCapitalized(str)).toBe("String With-Mixed_Separators"); |
| 742 | +describe("toDelimiter", () => { |
| 743 | + it("replace any non-alphanumeric character with custom delimiter", () => { |
| 744 | + const str = "this is a_string.with!non-alphanumeric#delimiters"; |
| 745 | + expect(toDelimiter(str, "_")).toBe("this_is_a_string_with_non_alphanumeric_delimiters"); |
745 | 746 | });
|
746 | 747 | });
|
0 commit comments