Files
discordeno/packages/utils/tests/casting.spec.ts
Jonathan Ho 432abcd204 test(utils): add utils tests (#2737)
* test(utils): add urltobase64 test

* test(utils): add token test

* test(utils): fix missing import buffer

* test(utils): add casting test

* test(utils): add casting test

* test(utils): fix use correct function
2023-01-24 09:39:57 -06:00

48 lines
1.2 KiB
TypeScript

import { expect } from 'chai'
import { describe, it } from 'mocha'
import { camelize, snakeToCamelCase } from '../src/casing.js'
describe('casting.ts', () => {
describe('camelize function', () => {
it('will convert snake case object to camel case object', () => {
expect(
camelize({
test_ax_by_cz: 'dummy_dx_ey_fz',
testgxhyiz: 'dummyjxkylz',
32: 'adw_dw',
}),
).to.deep.equal({
testAxByCz: 'dummy_dx_ey_fz',
testgxhyiz: 'dummyjxkylz',
32: 'adw_dw',
})
})
it('will convert array of snake case object to camel case object', () => {
expect(
camelize([
{
test_ax_by_cz: 'dummy_dx_ey_fz',
},
{
test_gx_hy_iz: 'dummy_jx_ky_lz',
},
]),
).to.deep.equal([
{
testAxByCz: 'dummy_dx_ey_fz',
},
{
testGxHyIz: 'dummy_jx_ky_lz',
},
])
})
describe('snakeToCamelCase function', () => {
it('will convert string snake case to camel case', () => {
expect(snakeToCamelCase('sd_sd')).to.equal('sdSd')
})
})
})
})