|
| 1 | +import { camelToSentenceCase } from ".."; |
| 2 | + |
| 3 | +describe("camelToSentenceCase", () => { |
| 4 | + test("should convert camelCase to sentence case", () => { |
| 5 | + expect(camelToSentenceCase("helloWorld")).toBe("Hello World"); |
| 6 | + expect(camelToSentenceCase("thisIsATest")).toBe("This Is A Test"); |
| 7 | + expect(camelToSentenceCase("convertThisFunction")).toBe( |
| 8 | + "Convert This Function" |
| 9 | + ); |
| 10 | + }); |
| 11 | + |
| 12 | + test("should handle PascalCase correctly", () => { |
| 13 | + expect(camelToSentenceCase("HelloWorld")).toBe("Hello World"); |
| 14 | + expect(camelToSentenceCase("ThisIsATest")).toBe("This Is A Test"); |
| 15 | + }); |
| 16 | + |
| 17 | + test("should handle acronyms within words", () => { |
| 18 | + expect(camelToSentenceCase("JSONParser")).toBe("JSON Parser"); |
| 19 | + expect(camelToSentenceCase("APITestCase")).toBe("API Test Case"); |
| 20 | + }); |
| 21 | + |
| 22 | + test("should handle single words without modification", () => { |
| 23 | + expect(camelToSentenceCase("hello")).toBe("Hello"); |
| 24 | + expect(camelToSentenceCase("Test")).toBe("Test"); |
| 25 | + }); |
| 26 | + |
| 27 | + test("should handle already spaced text without adding extra spaces", () => { |
| 28 | + expect(camelToSentenceCase("Already Spaced Text")).toBe( |
| 29 | + "Already Spaced Text" |
| 30 | + ); |
| 31 | + }); |
| 32 | + |
| 33 | + test("should handle empty strings gracefully", () => { |
| 34 | + expect(camelToSentenceCase("")).toBe(""); |
| 35 | + }); |
| 36 | + |
| 37 | + test("should handle strings with numbers", () => { |
| 38 | + expect(camelToSentenceCase("version2Update")).toBe("Version2Update"); |
| 39 | + }); |
| 40 | +}); |
0 commit comments