1
0
mirror of synced 2024-11-25 23:06:02 +03:00
vue-formulario/test/unit/utils/snakeToCamel.test.js

23 lines
773 B
JavaScript
Raw Normal View History

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)
})
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', () => {
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)
})
})