Skip to content

Commit 61f4a45

Browse files
committed
tests
1 parent b057efd commit 61f4a45

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

.eslintrc.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
2
2828
],
2929
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
30+
"quote-props": ["error", "as-needed"],
31+
"semi": ["error", "always"],
3032
"simple-import-sort/imports": 1,
3133
"simple-import-sort/exports": 1,
3234
"unused-imports/no-unused-imports": 1,

packages/casing/__tests__/casing.test.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,61 @@ it('should validate valid JavaScript-like identifiers allowing internal hyphens'
3232
expect(isValidIdentifierCamelized('-invalid-identifier')).toBe(false);
3333
expect(isValidIdentifierCamelized('invalid-identifier-')).toBe(true);
3434
});
35+
36+
describe('toPascalCase', () => {
37+
test('converts normal string', () => {
38+
expect(toPascalCase('hello_world')).toBe('HelloWorld');
39+
});
40+
41+
test('converts string with multiple underscores and mixed case', () => {
42+
expect(toPascalCase('Object_ID')).toBe('ObjectID');
43+
expect(toPascalCase('Postgre_SQL_View')).toBe('PostgreSQLView');
44+
expect(toPascalCase('postgre_sql_view')).toBe('PostgreSqlView');
45+
});
46+
47+
test('handles string with multiple separators together', () => {
48+
expect(toPascalCase('hello___world--great')).toBe('HelloWorldGreat');
49+
});
50+
51+
test('handles single word', () => {
52+
expect(toPascalCase('word')).toBe('Word');
53+
});
54+
55+
test('handles empty string', () => {
56+
expect(toPascalCase('')).toBe('');
57+
});
58+
59+
test('handles string with numbers', () => {
60+
expect(toPascalCase('version1_2_3')).toBe('Version123');
61+
});
62+
});
63+
64+
describe('toCamelCase', () => {
65+
test('converts hyphenated string', () => {
66+
expect(toCamelCase('hello-world')).toBe('helloWorld');
67+
});
68+
69+
test('converts underscored string', () => {
70+
expect(toCamelCase('hello_world')).toBe('helloWorld');
71+
});
72+
73+
test('converts spaces', () => {
74+
expect(toCamelCase('hello world')).toBe('helloWorld');
75+
});
76+
77+
test('handles mixed separators', () => {
78+
expect(toCamelCase('hello-world_now what')).toBe('helloWorldNowWhat');
79+
});
80+
81+
test('handles empty string', () => {
82+
expect(toCamelCase('')).toBe('');
83+
});
84+
85+
test('handles string starting with separators', () => {
86+
expect(toCamelCase('-hello_world')).toBe('helloWorld');
87+
});
88+
89+
test('handles string with multiple separators together', () => {
90+
expect(toCamelCase('hello___world--great')).toBe('helloWorldGreat');
91+
});
92+
});

0 commit comments

Comments
 (0)