Files
superset2/superset/assets/spec/javascripts/utils/convertKeysToCamelCase_spec.js
Krist Wongsuphasawat 8c83b72ce2 remove .only (#5943)
2018-09-20 10:42:22 -07:00

30 lines
1005 B
JavaScript

import { it, describe } from 'mocha';
import { expect } from 'chai';
import convertKeysToCamelCase from '../../../src/utils/convertKeysToCamelCase';
describe('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();
});
});