2020-10-26 00:07:23 +03:00
|
|
|
import snakeToCamel from '@/utils/snakeToCamel'
|
|
|
|
|
|
|
|
describe('snakeToCamel', () => {
|
2021-05-25 13:20:00 +03:00
|
|
|
test.each([
|
|
|
|
['this_is_snake_case', 'thisIsSnakeCase'],
|
|
|
|
['this_is_snake_case_2nd_example', 'thisIsSnakeCase2ndExample'],
|
|
|
|
])('converts snake_case to camelCase', (raw, expected) => {
|
|
|
|
expect(snakeToCamel(raw)).toBe(expected)
|
2020-10-26 00:07:23 +03:00
|
|
|
})
|
|
|
|
|
2021-05-25 13:20:00 +03:00
|
|
|
test('Does not capitalize the first word or strip first underscore if a phrase starts with an underscore', () => {
|
2020-10-26 00:07:23 +03:00
|
|
|
expect(snakeToCamel('_this_starts_with_an_underscore')).toBe('_thisStartsWithAnUnderscore')
|
|
|
|
})
|
|
|
|
|
2021-05-25 13:20:00 +03:00
|
|
|
test.each([
|
|
|
|
['thisIsCamelCase'],
|
|
|
|
['__double__underscores__'],
|
|
|
|
['this-is-kebab-case'],
|
|
|
|
])('has no effect', (raw) => {
|
|
|
|
expect(snakeToCamel(raw)).toBe(raw)
|
2020-10-26 00:07:23 +03:00
|
|
|
})
|
|
|
|
})
|