mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-01 08:20:08 +00:00
* close test(utils): more test for Collection.ts #2793 * fix: after each not defined * close test(utils): more test for base64.ts #2796 * close test(utils): more test for casing.ts #2797 * test(utils): remove dev code * close #2799 * fix #2800 * close #2823 * test(utils): fix site move * close #2826 * refactor(utils): remove redundant if * close #2827 * close #2828
90 lines
2.2 KiB
TypeScript
90 lines
2.2 KiB
TypeScript
import { expect } from 'chai'
|
|
import { describe, it } from 'mocha'
|
|
import { camelize, snakelize, 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')
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('snakelize function', () => {
|
|
it('will convert snake case object to camel case object', () => {
|
|
expect(
|
|
snakelize({
|
|
testAxByCz: 'dummy_dx_ey_fz',
|
|
testgxhyiz: 'dummyjxkylz',
|
|
32: 'adw_dw',
|
|
}),
|
|
).to.deep.equal({
|
|
test_ax_by_cz: 'dummy_dx_ey_fz',
|
|
testgxhyiz: 'dummyjxkylz',
|
|
32: 'adw_dw',
|
|
})
|
|
})
|
|
|
|
it('will convert array of snake case object to camel case object', () => {
|
|
expect(
|
|
snakelize([
|
|
{
|
|
testAxByCz: 'dummy_dx_ey_fz',
|
|
},
|
|
{
|
|
testGxHyIz: 'dummy_jx_ky_lz',
|
|
},
|
|
]),
|
|
).to.deep.equal([
|
|
{
|
|
test_ax_by_cz: 'dummy_dx_ey_fz',
|
|
},
|
|
{
|
|
test_gx_hy_iz: 'dummy_jx_ky_lz',
|
|
},
|
|
])
|
|
})
|
|
|
|
describe('snakeToCamelCase function', () => {
|
|
it('will convert string snake case to camel case', () => {
|
|
expect(snakeToCamelCase('sd_sd')).to.equal('sdSd')
|
|
})
|
|
})
|
|
})
|
|
})
|