|
7 | 7 | distinctPluralizeLast, |
8 | 8 | lcFirst, |
9 | 9 | ucFirst, |
| 10 | + camelize, |
| 11 | + underscore, |
10 | 12 | fixCapitalisedPlural, |
11 | 13 | toFieldName, |
12 | 14 | toQueryName, |
@@ -126,6 +128,43 @@ describe('ucFirst', () => { |
126 | 128 | }); |
127 | 129 | }); |
128 | 130 |
|
| 131 | +describe('camelize', () => { |
| 132 | + it('should convert snake_case to PascalCase by default', () => { |
| 133 | + expect(camelize('user_profile')).toBe('UserProfile'); |
| 134 | + expect(camelize('order_item')).toBe('OrderItem'); |
| 135 | + expect(camelize('api_schema')).toBe('ApiSchema'); |
| 136 | + }); |
| 137 | + |
| 138 | + it('should convert snake_case to camelCase when lowFirstLetter is true', () => { |
| 139 | + expect(camelize('user_profile', true)).toBe('userProfile'); |
| 140 | + expect(camelize('order_item', true)).toBe('orderItem'); |
| 141 | + expect(camelize('api_schema', true)).toBe('apiSchema'); |
| 142 | + }); |
| 143 | + |
| 144 | + it('should handle single words', () => { |
| 145 | + expect(camelize('user')).toBe('User'); |
| 146 | + expect(camelize('user', true)).toBe('user'); |
| 147 | + }); |
| 148 | +}); |
| 149 | + |
| 150 | +describe('underscore', () => { |
| 151 | + it('should convert PascalCase to snake_case', () => { |
| 152 | + expect(underscore('UserProfile')).toBe('user_profile'); |
| 153 | + expect(underscore('OrderItem')).toBe('order_item'); |
| 154 | + expect(underscore('ApiSchema')).toBe('api_schema'); |
| 155 | + }); |
| 156 | + |
| 157 | + it('should convert camelCase to snake_case', () => { |
| 158 | + expect(underscore('userProfile')).toBe('user_profile'); |
| 159 | + expect(underscore('orderItem')).toBe('order_item'); |
| 160 | + }); |
| 161 | + |
| 162 | + it('should handle single words', () => { |
| 163 | + expect(underscore('User')).toBe('user'); |
| 164 | + expect(underscore('user')).toBe('user'); |
| 165 | + }); |
| 166 | +}); |
| 167 | + |
129 | 168 | describe('fixCapitalisedPlural', () => { |
130 | 169 | it('should fix capitalized S after numbers', () => { |
131 | 170 | expect(fixCapitalisedPlural('Table1S')).toBe('Table1s'); |
|
0 commit comments