@ooneex/utils 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/capitalizeWord.d.ts +2 -0
  2. package/dist/capitalizeWord.d.ts.map +1 -0
  3. package/dist/dataURLtoFile.d.ts +2 -0
  4. package/dist/dataURLtoFile.d.ts.map +1 -0
  5. package/dist/formatRelativeNumber.d.ts +5 -0
  6. package/dist/formatRelativeNumber.d.ts.map +1 -0
  7. package/dist/index.d.ts +16 -69
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/millisecondsToHMS.d.ts +2 -0
  10. package/dist/millisecondsToHMS.d.ts.map +1 -0
  11. package/dist/parseEnvVars.d.ts +2 -0
  12. package/dist/parseEnvVars.d.ts.map +1 -0
  13. package/dist/parseString.d.ts +2 -0
  14. package/dist/parseString.d.ts.map +1 -0
  15. package/dist/random.d.ts +6 -0
  16. package/dist/random.d.ts.map +1 -0
  17. package/dist/secondsToHMS.d.ts +2 -0
  18. package/dist/secondsToHMS.d.ts.map +1 -0
  19. package/dist/secondsToMS.d.ts +2 -0
  20. package/dist/secondsToMS.d.ts.map +1 -0
  21. package/dist/sleep.d.ts +2 -0
  22. package/dist/sleep.d.ts.map +1 -0
  23. package/dist/splitToWords.d.ts +2 -0
  24. package/dist/splitToWords.d.ts.map +1 -0
  25. package/dist/toCamelCase.d.ts +2 -0
  26. package/dist/toCamelCase.d.ts.map +1 -0
  27. package/dist/toKebabCase.d.ts +2 -0
  28. package/dist/toKebabCase.d.ts.map +1 -0
  29. package/dist/toPascalCase.d.ts +2 -0
  30. package/dist/toPascalCase.d.ts.map +1 -0
  31. package/dist/trim.d.ts +2 -0
  32. package/dist/trim.d.ts.map +1 -0
  33. package/package.json +12 -9
  34. package/src/capitalizeWord.ts +3 -0
  35. package/src/dataURLtoFile.ts +12 -0
  36. package/src/formatRelativeNumber.ts +7 -0
  37. package/src/index.ts +15 -0
  38. package/src/millisecondsToHMS.ts +16 -0
  39. package/src/parseEnvVars.ts +14 -0
  40. package/src/parseString.ts +47 -0
  41. package/src/random.ts +13 -0
  42. package/src/secondsToHMS.ts +16 -0
  43. package/src/secondsToMS.ts +5 -0
  44. package/src/sleep.ts +3 -0
  45. package/src/splitToWords.ts +14 -0
  46. package/src/toCamelCase.ts +8 -0
  47. package/src/toKebabCase.ts +6 -0
  48. package/src/toPascalCase.ts +7 -0
  49. package/src/trim.ts +8 -0
  50. package/tests/capitalizeWord.spec.ts +163 -0
  51. package/tests/dataURLtoFile.spec.ts +472 -0
  52. package/tests/formatRelativeNumber.spec.ts +303 -0
  53. package/tests/millisecondsToHMS.spec.ts +209 -0
  54. package/tests/parseEnvVars.spec.ts +468 -0
  55. package/tests/parseString.spec.ts +377 -0
  56. package/tests/random.spec.ts +422 -0
  57. package/tests/secondsToHMS.spec.ts +341 -0
  58. package/tests/secondsToMS.spec.ts +467 -0
  59. package/tests/splitToWords.spec.ts +359 -0
  60. package/tests/toCamelCase.spec.ts +526 -0
  61. package/tests/toKebabCase.spec.ts +664 -0
  62. package/tests/toPascalCase.spec.ts +721 -0
  63. package/tests/trim.spec.ts +486 -0
  64. package/tsconfig.build.json +14 -0
  65. package/tsconfig.json +11 -0
@@ -0,0 +1,721 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { toPascalCase } from "@/index";
3
+
4
+ describe("toPascalCase", () => {
5
+ describe("basic functionality", () => {
6
+ test("should convert simple lowercase words", () => {
7
+ expect(toPascalCase("hello world")).toBe("HelloWorld");
8
+ });
9
+
10
+ test("should convert capitalized words", () => {
11
+ expect(toPascalCase("Hello World")).toBe("HelloWorld");
12
+ });
13
+
14
+ test("should convert single word to capitalized", () => {
15
+ expect(toPascalCase("hello")).toBe("Hello");
16
+ });
17
+
18
+ test("should convert single capitalized word to capitalized", () => {
19
+ expect(toPascalCase("Hello")).toBe("Hello");
20
+ });
21
+
22
+ test("should handle empty string", () => {
23
+ expect(toPascalCase("")).toBe("");
24
+ });
25
+
26
+ test("should handle whitespace only", () => {
27
+ expect(toPascalCase(" ")).toBe("");
28
+ });
29
+
30
+ test("should convert multiple words", () => {
31
+ expect(toPascalCase("hello world test")).toBe("HelloWorldTest");
32
+ });
33
+
34
+ test("should handle mixed case input", () => {
35
+ expect(toPascalCase("HeLLo WoRLd")).toBe("HeLLoWoRLd");
36
+ });
37
+ });
38
+
39
+ describe("camelCase conversion", () => {
40
+ test("should convert camelCase string", () => {
41
+ expect(toPascalCase("camelCase")).toBe("CamelCase");
42
+ });
43
+
44
+ test("should handle already PascalCase string", () => {
45
+ expect(toPascalCase("PascalCase")).toBe("PascalCase");
46
+ });
47
+
48
+ test("should convert complex camelCase", () => {
49
+ expect(toPascalCase("getUserProfile")).toBe("GetUserProfile");
50
+ });
51
+
52
+ test("should convert camelCase with numbers", () => {
53
+ expect(toPascalCase("user123Profile")).toBe("User123Profile");
54
+ });
55
+
56
+ test("should handle single camelCase word", () => {
57
+ expect(toPascalCase("hello")).toBe("Hello");
58
+ });
59
+
60
+ test("should handle alternating case", () => {
61
+ expect(toPascalCase("aBcDeFg")).toBe("ABcDeFg");
62
+ });
63
+ });
64
+
65
+ describe("snake_case conversion", () => {
66
+ test("should convert simple snake_case", () => {
67
+ expect(toPascalCase("hello_world")).toBe("HelloWorld");
68
+ });
69
+
70
+ test("should convert multiple snake_case words", () => {
71
+ expect(toPascalCase("hello_world_test")).toBe("HelloWorldTest");
72
+ });
73
+
74
+ test("should convert uppercase snake_case", () => {
75
+ expect(toPascalCase("HELLO_WORLD")).toBe("HelloWorld");
76
+ });
77
+
78
+ test("should convert mixed case snake_case", () => {
79
+ expect(toPascalCase("Hello_World_Test")).toBe("HelloWorldTest");
80
+ });
81
+
82
+ test("should handle leading underscore", () => {
83
+ expect(toPascalCase("_hello_world")).toBe("HelloWorld");
84
+ });
85
+
86
+ test("should handle trailing underscore", () => {
87
+ expect(toPascalCase("hello_world_")).toBe("HelloWorld");
88
+ });
89
+
90
+ test("should handle multiple underscores", () => {
91
+ expect(toPascalCase("hello__world")).toBe("HelloWorld");
92
+ });
93
+ });
94
+
95
+ describe("kebab-case conversion", () => {
96
+ test("should convert simple kebab-case", () => {
97
+ expect(toPascalCase("hello-world")).toBe("HelloWorld");
98
+ });
99
+
100
+ test("should convert multiple kebab-case words", () => {
101
+ expect(toPascalCase("hello-world-test")).toBe("HelloWorldTest");
102
+ });
103
+
104
+ test("should convert uppercase kebab-case", () => {
105
+ expect(toPascalCase("HELLO-WORLD")).toBe("HelloWorld");
106
+ });
107
+
108
+ test("should convert mixed case kebab-case", () => {
109
+ expect(toPascalCase("Hello-World-Test")).toBe("HelloWorldTest");
110
+ });
111
+
112
+ test("should handle leading hyphen", () => {
113
+ expect(toPascalCase("-hello-world")).toBe("HelloWorld");
114
+ });
115
+
116
+ test("should handle trailing hyphen", () => {
117
+ expect(toPascalCase("hello-world-")).toBe("HelloWorld");
118
+ });
119
+
120
+ test("should handle multiple hyphens", () => {
121
+ expect(toPascalCase("hello--world")).toBe("HelloWorld");
122
+ });
123
+ });
124
+
125
+ describe("dot.case conversion", () => {
126
+ test("should convert dot separated words", () => {
127
+ expect(toPascalCase("hello.world")).toBe("HelloWorld");
128
+ });
129
+
130
+ test("should convert multiple dot separated words", () => {
131
+ expect(toPascalCase("hello.world.test")).toBe("HelloWorldTest");
132
+ });
133
+
134
+ test("should convert mixed case dot separated", () => {
135
+ expect(toPascalCase("Hello.World.Test")).toBe("HelloWorldTest");
136
+ });
137
+
138
+ test("should handle leading dot", () => {
139
+ expect(toPascalCase(".hello.world")).toBe("HelloWorld");
140
+ });
141
+
142
+ test("should handle trailing dot", () => {
143
+ expect(toPascalCase("hello.world.")).toBe("HelloWorld");
144
+ });
145
+ });
146
+
147
+ describe("numbers handling", () => {
148
+ test("should handle words with numbers", () => {
149
+ expect(toPascalCase("hello123 world456")).toBe("Hello123World456");
150
+ });
151
+
152
+ test("should handle standalone numbers", () => {
153
+ expect(toPascalCase("hello 123 world")).toBe("Hello123World");
154
+ });
155
+
156
+ test("should handle numbers at start", () => {
157
+ expect(toPascalCase("123 hello world")).toBe("123HelloWorld");
158
+ });
159
+
160
+ test("should handle version-like patterns", () => {
161
+ expect(toPascalCase("version 1.2.3")).toBe("Version123");
162
+ });
163
+
164
+ test("should handle mixed numbers and letters", () => {
165
+ expect(toPascalCase("user123 profile456 test")).toBe("User123Profile456Test");
166
+ });
167
+
168
+ test("should handle camelCase with numbers", () => {
169
+ expect(toPascalCase("version2Beta3")).toBe("Version2Beta3");
170
+ });
171
+ });
172
+
173
+ describe("acronyms handling", () => {
174
+ test("should handle simple acronyms", () => {
175
+ expect(toPascalCase("ID")).toBe("Id");
176
+ });
177
+
178
+ test("should handle URL acronym", () => {
179
+ expect(toPascalCase("URL")).toBe("Url");
180
+ });
181
+
182
+ test("should handle acronym with words", () => {
183
+ expect(toPascalCase("HTML Element")).toBe("HtmlElement");
184
+ });
185
+
186
+ test("should handle multiple acronyms", () => {
187
+ expect(toPascalCase("HTTP API")).toBe("HttpApi");
188
+ });
189
+
190
+ test("should handle acronym at end", () => {
191
+ expect(toPascalCase("parse XML")).toBe("ParseXml");
192
+ });
193
+
194
+ test("should handle mixed acronyms and words", () => {
195
+ expect(toPascalCase("XML Http Request")).toBe("XmlHttpRequest");
196
+ });
197
+
198
+ test("should handle complex acronym patterns", () => {
199
+ expect(toPascalCase("XMLParser")).toBe("XmlParser");
200
+ expect(toPascalCase("HTTPApi")).toBe("HttpApi");
201
+ expect(toPascalCase("JSONData")).toBe("JsonData");
202
+ });
203
+
204
+ test("should handle acronym patterns correctly", () => {
205
+ expect(toPascalCase("parseHTML5Document")).toBe("ParseHtml5Document");
206
+ expect(toPascalCase("XMLHttpRequestV2")).toBe("XmlHttpRequestV2");
207
+ });
208
+ });
209
+
210
+ describe("mixed separators", () => {
211
+ test("should handle mixed hyphen and underscore", () => {
212
+ expect(toPascalCase("hello-world_test")).toBe("HelloWorldTest");
213
+ });
214
+
215
+ test("should handle mixed separators with spaces", () => {
216
+ expect(toPascalCase("hello-world test_case")).toBe("HelloWorldTestCase");
217
+ });
218
+
219
+ test("should handle all separator types", () => {
220
+ expect(toPascalCase("hello-world_test.case api")).toBe("HelloWorldTestCaseApi");
221
+ });
222
+
223
+ test("should handle multiple mixed separators", () => {
224
+ expect(toPascalCase("hello--world__test..case")).toBe("HelloWorldTestCase");
225
+ });
226
+
227
+ test("should handle camelCase with separators", () => {
228
+ expect(toPascalCase("helloWorld_testCase-apiKey")).toBe("HelloWorldTestCaseApiKey");
229
+ });
230
+ });
231
+
232
+ describe("special characters", () => {
233
+ test("should ignore punctuation", () => {
234
+ expect(toPascalCase("hello, world!")).toBe("HelloWorld");
235
+ });
236
+
237
+ test("should handle parentheses", () => {
238
+ expect(toPascalCase("hello(world)")).toBe("HelloWorld");
239
+ });
240
+
241
+ test("should handle brackets", () => {
242
+ expect(toPascalCase("hello[world]")).toBe("HelloWorld");
243
+ });
244
+
245
+ test("should handle braces", () => {
246
+ expect(toPascalCase("hello{world}")).toBe("HelloWorld");
247
+ });
248
+
249
+ test("should handle quotes", () => {
250
+ expect(toPascalCase("'hello' \"world\"")).toBe("HelloWorld");
251
+ });
252
+
253
+ test("should handle mixed special characters", () => {
254
+ expect(toPascalCase("hello@#$%world^&*test")).toBe("HelloWorldTest");
255
+ });
256
+
257
+ test("should handle complex punctuation patterns", () => {
258
+ expect(toPascalCase("hello... world??? test!!!")).toBe("HelloWorldTest");
259
+ });
260
+ });
261
+
262
+ describe("unicode and international characters", () => {
263
+ test("should handle accented characters", () => {
264
+ expect(toPascalCase("café résumé")).toBe("CaféRésumé");
265
+ });
266
+
267
+ test("should handle cyrillic characters", () => {
268
+ expect(toPascalCase("привет мир")).toBe("ПриветМир");
269
+ });
270
+
271
+ test("should handle chinese characters", () => {
272
+ expect(toPascalCase("你好 世界")).toBe("你好世界");
273
+ });
274
+
275
+ test("should handle arabic characters", () => {
276
+ expect(toPascalCase("مرحبا بالعالم")).toBe("مرحبابالعالم");
277
+ });
278
+
279
+ test("should handle mixed latin and unicode", () => {
280
+ expect(toPascalCase("hello 世界")).toBe("Hello世界");
281
+ });
282
+
283
+ test("should handle emoji with text", () => {
284
+ expect(toPascalCase("hello 😀 world")).toBe("HelloWorld");
285
+ });
286
+
287
+ test("should handle unicode camelCase", () => {
288
+ expect(toPascalCase("caféWorld")).toBe("CaféWorld");
289
+ });
290
+ });
291
+
292
+ describe("whitespace handling", () => {
293
+ test("should handle leading whitespace", () => {
294
+ expect(toPascalCase(" hello world")).toBe("HelloWorld");
295
+ });
296
+
297
+ test("should handle trailing whitespace", () => {
298
+ expect(toPascalCase("hello world ")).toBe("HelloWorld");
299
+ });
300
+
301
+ test("should handle multiple spaces", () => {
302
+ expect(toPascalCase("hello world")).toBe("HelloWorld");
303
+ });
304
+
305
+ test("should handle tabs", () => {
306
+ expect(toPascalCase("hello\tworld")).toBe("HelloWorld");
307
+ });
308
+
309
+ test("should handle newlines", () => {
310
+ expect(toPascalCase("hello\nworld")).toBe("HelloWorld");
311
+ });
312
+
313
+ test("should handle mixed whitespace", () => {
314
+ expect(toPascalCase(" hello \t world \n test ")).toBe("HelloWorldTest");
315
+ });
316
+
317
+ test("should handle only whitespace", () => {
318
+ expect(toPascalCase(" \t\n ")).toBe("");
319
+ });
320
+ });
321
+
322
+ describe("edge cases", () => {
323
+ test("should handle single character", () => {
324
+ expect(toPascalCase("a")).toBe("A");
325
+ });
326
+
327
+ test("should handle single uppercase character", () => {
328
+ expect(toPascalCase("A")).toBe("A");
329
+ });
330
+
331
+ test("should handle single number", () => {
332
+ expect(toPascalCase("1")).toBe("1");
333
+ });
334
+
335
+ test("should handle alternating case input", () => {
336
+ expect(toPascalCase("aBcDeFg")).toBe("ABcDeFg");
337
+ });
338
+
339
+ test("should handle all uppercase input", () => {
340
+ expect(toPascalCase("HELLO")).toBe("Hello");
341
+ });
342
+
343
+ test("should handle all lowercase input", () => {
344
+ expect(toPascalCase("hello")).toBe("Hello");
345
+ });
346
+
347
+ test("should handle numbers only", () => {
348
+ expect(toPascalCase("123456")).toBe("123456");
349
+ });
350
+
351
+ test("should handle special characters only", () => {
352
+ expect(toPascalCase("!@#$%^&*()")).toBe("");
353
+ });
354
+
355
+ test("should handle very short inputs", () => {
356
+ expect(toPascalCase("a b")).toBe("AB");
357
+ expect(toPascalCase("A B")).toBe("AB");
358
+ expect(toPascalCase("1 2")).toBe("12");
359
+ });
360
+
361
+ test("should handle separator only", () => {
362
+ expect(toPascalCase("-")).toBe("");
363
+ expect(toPascalCase("_")).toBe("");
364
+ expect(toPascalCase(".")).toBe("");
365
+ });
366
+
367
+ test("should handle multiple separators only", () => {
368
+ expect(toPascalCase("---")).toBe("");
369
+ expect(toPascalCase("___")).toBe("");
370
+ expect(toPascalCase("...")).toBe("");
371
+ });
372
+ });
373
+
374
+ describe("real-world examples", () => {
375
+ test("should convert JavaScript function names", () => {
376
+ expect(toPascalCase("getElementById")).toBe("GetElementById");
377
+ expect(toPascalCase("addEventListener")).toBe("AddEventListener");
378
+ expect(toPascalCase("querySelector")).toBe("QuerySelector");
379
+ });
380
+
381
+ test("should convert CSS class names to component names", () => {
382
+ expect(toPascalCase("btn-primary")).toBe("BtnPrimary");
383
+ expect(toPascalCase("form-control")).toBe("FormControl");
384
+ expect(toPascalCase("navbar-brand")).toBe("NavbarBrand");
385
+ });
386
+
387
+ test("should convert database column names", () => {
388
+ expect(toPascalCase("user_id")).toBe("UserId");
389
+ expect(toPascalCase("created_at")).toBe("CreatedAt");
390
+ expect(toPascalCase("first_name")).toBe("FirstName");
391
+ });
392
+
393
+ test("should convert API endpoint names", () => {
394
+ expect(toPascalCase("get user by id")).toBe("GetUserById");
395
+ expect(toPascalCase("create user profile")).toBe("CreateUserProfile");
396
+ expect(toPascalCase("update password")).toBe("UpdatePassword");
397
+ });
398
+
399
+ test("should convert file names to class names", () => {
400
+ expect(toPascalCase("my-file.txt")).toBe("MyFileTxt");
401
+ expect(toPascalCase("user_profile.json")).toBe("UserProfileJson");
402
+ expect(toPascalCase("config-dev.yaml")).toBe("ConfigDevYaml");
403
+ });
404
+
405
+ test("should convert package names to class names", () => {
406
+ expect(toPascalCase("react-dom")).toBe("ReactDom");
407
+ expect(toPascalCase("lodash.get")).toBe("LodashGet");
408
+ expect(toPascalCase("types/node")).toBe("TypesNode");
409
+ });
410
+
411
+ test("should convert technical terms", () => {
412
+ expect(toPascalCase("xml http request")).toBe("XmlHttpRequest");
413
+ expect(toPascalCase("json web token")).toBe("JsonWebToken");
414
+ expect(toPascalCase("rest api")).toBe("RestApi");
415
+ });
416
+
417
+ test("should convert component names", () => {
418
+ expect(toPascalCase("user-profile")).toBe("UserProfile");
419
+ expect(toPascalCase("navbar_component")).toBe("NavbarComponent");
420
+ expect(toPascalCase("button.group")).toBe("ButtonGroup");
421
+ });
422
+ });
423
+
424
+ describe("parametrized tests", () => {
425
+ test.each([
426
+ ["hello world", "HelloWorld"],
427
+ ["Hello World", "HelloWorld"],
428
+ ["HELLO WORLD", "HelloWorld"],
429
+ ["hello-world", "HelloWorld"],
430
+ ["hello_world", "HelloWorld"],
431
+ ["hello.world", "HelloWorld"],
432
+ ["helloWorld", "HelloWorld"],
433
+ ["HelloWorld", "HelloWorld"],
434
+ ["camelCase", "CamelCase"],
435
+ ["PascalCase", "PascalCase"],
436
+ ["hello", "Hello"],
437
+ ["Hello", "Hello"],
438
+ ["HELLO", "Hello"],
439
+ ["hello123", "Hello123"],
440
+ ["123hello", "123Hello"],
441
+ ["XMLParser", "XmlParser"],
442
+ ["parseXML", "ParseXml"],
443
+ ["HTML5", "Html5"],
444
+ ["getUserById", "GetUserById"],
445
+ ["user_id", "UserId"],
446
+ ["API", "Api"],
447
+ ["", ""],
448
+ [" ", ""],
449
+ ["a", "A"],
450
+ ["A", "A"],
451
+ ["1", "1"],
452
+ ["hello world test", "HelloWorldTest"],
453
+ ["HELLO_WORLD_TEST", "HelloWorldTest"],
454
+ ["hello-world-test", "HelloWorldTest"],
455
+ ["hello.world.test", "HelloWorldTest"],
456
+ ["helloWorldTest", "HelloWorldTest"],
457
+ ["HTTPSProxy", "HttpsProxy"],
458
+ ["iPhone14Pro", "IPhone14Pro"],
459
+ ["myReactComponent", "MyReactComponent"],
460
+ ["VUE_JS_APP", "VueJsApp"],
461
+ ["angular.material.button", "AngularMaterialButton"],
462
+ ])("toPascalCase(%s) should return %s", (input, expected) => {
463
+ expect(toPascalCase(input)).toBe(expected);
464
+ });
465
+ });
466
+
467
+ describe("complex patterns", () => {
468
+ test("should handle complex mixed patterns", () => {
469
+ expect(toPascalCase("parseHTML5Document")).toBe("ParseHtml5Document");
470
+ });
471
+
472
+ test("should handle version numbers", () => {
473
+ expect(toPascalCase("v1.2.3-beta")).toBe("V123Beta");
474
+ });
475
+
476
+ test("should handle technical terms with versions", () => {
477
+ expect(toPascalCase("XMLHttpRequestV2")).toBe("XmlHttpRequestV2");
478
+ });
479
+
480
+ test("should handle namespace-like patterns", () => {
481
+ expect(toPascalCase("com.example.MyClass")).toBe("ComExampleMyClass");
482
+ });
483
+
484
+ test("should handle URL-like patterns", () => {
485
+ expect(toPascalCase("http API Server")).toBe("HttpApiServer");
486
+ });
487
+
488
+ test("should handle constant names", () => {
489
+ expect(toPascalCase("MAX_USER_COUNT")).toBe("MaxUserCount");
490
+ });
491
+
492
+ test("should handle mixed case with numbers and separators", () => {
493
+ expect(toPascalCase("iPhone14-Pro_Max")).toBe("IPhone14ProMax");
494
+ });
495
+
496
+ test("should handle complex real-world examples", () => {
497
+ expect(toPascalCase("XMLHttpRequest-v2.0_beta")).toBe("XmlHttpRequestV20Beta");
498
+ expect(toPascalCase("getUserProfile_byId-V3")).toBe("GetUserProfileByIdV3");
499
+ expect(toPascalCase("API_KEY_VERSION_2")).toBe("ApiKeyVersion2");
500
+ });
501
+
502
+ test("should handle framework component names", () => {
503
+ expect(toPascalCase("MyAwesomeReactComponent")).toBe("MyAwesomeReactComponent");
504
+ expect(toPascalCase("VueJSAppRouter")).toBe("VueJsAppRouter");
505
+ expect(toPascalCase("AngularMaterialButton")).toBe("AngularMaterialButton");
506
+ });
507
+ });
508
+
509
+ describe("function behavior", () => {
510
+ test("should return string type", () => {
511
+ const result = toPascalCase("test");
512
+ expect(typeof result).toBe("string");
513
+ });
514
+
515
+ test("should not mutate input", () => {
516
+ const original = "helloWorld";
517
+ const result = toPascalCase(original);
518
+ expect(original).toBe("helloWorld");
519
+ expect(result).toBe("HelloWorld");
520
+ });
521
+
522
+ test("should return same result for multiple calls", () => {
523
+ const input = "helloWorld";
524
+ const result1 = toPascalCase(input);
525
+ const result2 = toPascalCase(input);
526
+ expect(result1).toBe(result2);
527
+ expect(result1).toBe("HelloWorld");
528
+ });
529
+
530
+ test("should handle very long strings", () => {
531
+ const longString = `${"hello".repeat(1000)}World`;
532
+ const result = toPascalCase(longString);
533
+ expect(result).toMatch(/^Hello/);
534
+ expect(result).toMatch(/World$/);
535
+ expect(result).not.toContain("-");
536
+ expect(result).not.toContain("_");
537
+ expect(result).not.toContain(" ");
538
+ });
539
+
540
+ test("should be consistent with dependencies", () => {
541
+ // Test consistency with splitToWords and capitalizeWord behavior
542
+ expect(toPascalCase("XMLParser")).toBe("XmlParser");
543
+ expect(toPascalCase("parseXML")).toBe("ParseXml");
544
+ expect(toPascalCase("HTMLElement")).toBe("HtmlElement");
545
+ });
546
+
547
+ test("should handle consecutive calls consistently", () => {
548
+ const input = "complexTestCase123";
549
+ const result1 = toPascalCase(input);
550
+ const result2 = toPascalCase(input);
551
+ const result3 = toPascalCase(input);
552
+
553
+ expect(result1).toBe(result2);
554
+ expect(result2).toBe(result3);
555
+ expect(result1).toBe("ComplexTestCase123");
556
+ });
557
+ });
558
+
559
+ describe("performance considerations", () => {
560
+ test("should handle empty input efficiently", () => {
561
+ expect(toPascalCase("")).toBe("");
562
+ });
563
+
564
+ test("should handle whitespace-only input efficiently", () => {
565
+ expect(toPascalCase(" \n\t ")).toBe("");
566
+ });
567
+
568
+ test("should handle special characters only efficiently", () => {
569
+ expect(toPascalCase("!@#$%^&*()_+-=[]{}|;:,.<>?")).toBe("");
570
+ });
571
+
572
+ test("should handle single word efficiently", () => {
573
+ expect(toPascalCase("hello")).toBe("Hello");
574
+ expect(toPascalCase("Hello")).toBe("Hello");
575
+ expect(toPascalCase("HELLO")).toBe("Hello");
576
+ });
577
+
578
+ test("should handle already PascalCase efficiently", () => {
579
+ expect(toPascalCase("HelloWorld")).toBe("HelloWorld");
580
+ expect(toPascalCase("HelloWorldTest")).toBe("HelloWorldTest");
581
+ });
582
+ });
583
+
584
+ describe("integration with dependencies", () => {
585
+ test("should work correctly with splitToWords edge cases", () => {
586
+ // Test cases that rely heavily on splitToWords behavior
587
+ expect(toPascalCase("XMLHttpRequest")).toBe("XmlHttpRequest");
588
+ expect(toPascalCase("parseHTML5Document")).toBe("ParseHtml5Document");
589
+ expect(toPascalCase("getUserProfile123")).toBe("GetUserProfile123");
590
+ });
591
+
592
+ test("should work correctly with capitalizeWord edge cases", () => {
593
+ // Test cases that rely heavily on capitalizeWord behavior
594
+ expect(toPascalCase("hello world")).toBe("HelloWorld");
595
+ expect(toPascalCase("HELLO WORLD")).toBe("HelloWorld");
596
+ expect(toPascalCase("café résumé")).toBe("CaféRésumé");
597
+ });
598
+
599
+ test("should handle trim behavior correctly", () => {
600
+ expect(toPascalCase(" hello world ")).toBe("HelloWorld");
601
+ expect(toPascalCase("\t\nhelloWorld\t\n")).toBe("HelloWorld");
602
+ expect(toPascalCase(" ")).toBe("");
603
+ });
604
+
605
+ test("should work with splitToWords acronym handling", () => {
606
+ expect(toPascalCase("HTTPSProxy")).toBe("HttpsProxy");
607
+ expect(toPascalCase("APIKeyManager")).toBe("ApiKeyManager");
608
+ expect(toPascalCase("JSONWebToken")).toBe("JsonWebToken");
609
+ });
610
+
611
+ test("should handle splitToWords number patterns", () => {
612
+ expect(toPascalCase("version2Beta3Release")).toBe("Version2Beta3Release");
613
+ expect(toPascalCase("HTML5Parser")).toBe("Html5Parser");
614
+ expect(toPascalCase("CSS3Animation")).toBe("Css3Animation");
615
+ });
616
+ });
617
+
618
+ describe("React component naming scenarios", () => {
619
+ test("should convert component prop names", () => {
620
+ expect(toPascalCase("isLoading")).toBe("IsLoading");
621
+ expect(toPascalCase("hasError")).toBe("HasError");
622
+ expect(toPascalCase("showModal")).toBe("ShowModal");
623
+ });
624
+
625
+ test("should convert component state names", () => {
626
+ expect(toPascalCase("userProfile")).toBe("UserProfile");
627
+ expect(toPascalCase("authToken")).toBe("AuthToken");
628
+ expect(toPascalCase("apiResponse")).toBe("ApiResponse");
629
+ });
630
+
631
+ test("should convert hook names", () => {
632
+ expect(toPascalCase("useEffect")).toBe("UseEffect");
633
+ expect(toPascalCase("useState")).toBe("UseState");
634
+ expect(toPascalCase("useCustomHook")).toBe("UseCustomHook");
635
+ });
636
+
637
+ test("should convert context names", () => {
638
+ expect(toPascalCase("authContext")).toBe("AuthContext");
639
+ expect(toPascalCase("themeProvider")).toBe("ThemeProvider");
640
+ expect(toPascalCase("userDataContext")).toBe("UserDataContext");
641
+ });
642
+ });
643
+
644
+ describe("class and interface naming scenarios", () => {
645
+ test("should convert class names", () => {
646
+ expect(toPascalCase("userService")).toBe("UserService");
647
+ expect(toPascalCase("authenticationManager")).toBe("AuthenticationManager");
648
+ expect(toPascalCase("databaseConnection")).toBe("DatabaseConnection");
649
+ });
650
+
651
+ test("should convert interface names", () => {
652
+ expect(toPascalCase("userInterface")).toBe("UserInterface");
653
+ expect(toPascalCase("apiResponse")).toBe("ApiResponse");
654
+ expect(toPascalCase("configOptions")).toBe("ConfigOptions");
655
+ });
656
+
657
+ test("should convert type names", () => {
658
+ expect(toPascalCase("userType")).toBe("UserType");
659
+ expect(toPascalCase("apiEndpoint")).toBe("ApiEndpoint");
660
+ expect(toPascalCase("httpMethod")).toBe("HttpMethod");
661
+ });
662
+
663
+ test("should convert enum names", () => {
664
+ expect(toPascalCase("userStatus")).toBe("UserStatus");
665
+ expect(toPascalCase("orderState")).toBe("OrderState");
666
+ expect(toPascalCase("paymentMethod")).toBe("PaymentMethod");
667
+ });
668
+ });
669
+
670
+ describe("framework-specific scenarios", () => {
671
+ test("should convert Vue component names", () => {
672
+ expect(toPascalCase("my-component")).toBe("MyComponent");
673
+ expect(toPascalCase("user-profile-card")).toBe("UserProfileCard");
674
+ expect(toPascalCase("navigation-bar")).toBe("NavigationBar");
675
+ });
676
+
677
+ test("should convert Angular component names", () => {
678
+ expect(toPascalCase("app-header")).toBe("AppHeader");
679
+ expect(toPascalCase("user-list-item")).toBe("UserListItem");
680
+ expect(toPascalCase("form-input-field")).toBe("FormInputField");
681
+ });
682
+
683
+ test("should convert service names", () => {
684
+ expect(toPascalCase("data-service")).toBe("DataService");
685
+ expect(toPascalCase("auth-guard")).toBe("AuthGuard");
686
+ expect(toPascalCase("http-interceptor")).toBe("HttpInterceptor");
687
+ });
688
+
689
+ test("should convert module names", () => {
690
+ expect(toPascalCase("user-module")).toBe("UserModule");
691
+ expect(toPascalCase("shared-module")).toBe("SharedModule");
692
+ expect(toPascalCase("core-module")).toBe("CoreModule");
693
+ });
694
+ });
695
+
696
+ describe("API and backend scenarios", () => {
697
+ test("should convert model names", () => {
698
+ expect(toPascalCase("user-model")).toBe("UserModel");
699
+ expect(toPascalCase("order_item")).toBe("OrderItem");
700
+ expect(toPascalCase("product.category")).toBe("ProductCategory");
701
+ });
702
+
703
+ test("should convert controller names", () => {
704
+ expect(toPascalCase("user_controller")).toBe("UserController");
705
+ expect(toPascalCase("auth-controller")).toBe("AuthController");
706
+ expect(toPascalCase("api.controller")).toBe("ApiController");
707
+ });
708
+
709
+ test("should convert middleware names", () => {
710
+ expect(toPascalCase("auth_middleware")).toBe("AuthMiddleware");
711
+ expect(toPascalCase("cors-middleware")).toBe("CorsMiddleware");
712
+ expect(toPascalCase("logging.middleware")).toBe("LoggingMiddleware");
713
+ });
714
+
715
+ test("should convert repository names", () => {
716
+ expect(toPascalCase("user_repository")).toBe("UserRepository");
717
+ expect(toPascalCase("order-repository")).toBe("OrderRepository");
718
+ expect(toPascalCase("product.repository")).toBe("ProductRepository");
719
+ });
720
+ });
721
+ });