Files
superset2/superset/assets/spec/javascripts/utils/convertKeysToCamelCase_spec.js
Krist Wongsuphasawat 8fff0d9e8f [SIP-6] Add reactify function and convert world map to new directory structure. (#5893)
* reactify world map

* add createAdaptor

* fix typo

* add schema

* move directory

* remove unnecessary lines

* make setRef a function

* convert keys to camelcase

* add unit test

* update formatting

* add check for displayName

* pass width and height as separate inputs
2018-09-18 23:35:36 -07:00

30 lines
1010 B
JavaScript

import { it, describe } from 'mocha';
import { expect } from 'chai';
import convertKeysToCamelCase from '../../../src/utils/convertKeysToCamelCase';
describe.only('convertKeysToCamelCase(object)', () => {
it('returns undefined for undefined input', () => {
expect(convertKeysToCamelCase(undefined)).to.equal(undefined);
});
it('returns null for null input', () => {
expect(convertKeysToCamelCase(null)).to.equal(null);
});
it('returns a new object that has all keys in camelCase', () => {
const input = {
is_happy: true,
'is-angry': false,
isHungry: false,
};
expect(convertKeysToCamelCase(input)).to.deep.equal({
isHappy: true,
isAngry: false,
isHungry: false,
});
});
it('throws error if input is not a plain object', () => {
expect(() => { convertKeysToCamelCase({}); }).to.not.throw();
expect(() => { convertKeysToCamelCase(''); }).to.throw();
expect(() => { convertKeysToCamelCase(new Map()); }).to.throw();
});
});