1
0
mirror of synced 2024-12-19 01:58:47 +03:00
vue-formulario/test/unit/utils/snakeToCamel.test.js
2021-06-14 14:02:09 +03:00

23 lines
773 B
JavaScript

import snakeToCamel from '@/utils/snakeToCamel'
describe('snakeToCamel', () => {
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)
})
test('Does not capitalize the first word or strip first underscore if a phrase starts with an underscore', () => {
expect(snakeToCamel('_this_starts_with_an_underscore')).toBe('_thisStartsWithAnUnderscore')
})
test.each([
['thisIsCamelCase'],
['__double__underscores__'],
['this-is-kebab-case'],
])('has no effect', (raw) => {
expect(snakeToCamel(raw)).toBe(raw)
})
})