vcc-ui
Version:
VCC UI is a collection of React UI Components that can be used for developing front-end applications at Volvo Car Corporation.
55 lines (44 loc) • 883 B
JavaScript
import { renameKeys } from './rename-keys';
describe('renameKeys()', () => {
it('performs an immutable renaming of keys on a given object', () => {
const mock = {
foo: 128,
bar: 256,
};
const result = renameKeys({
foo: 'FOO',
bar: 'bar-new',
})(mock);
expect(result).toEqual({
FOO: 128,
'bar-new': 256,
});
expect(mock).toEqual({
foo: 128,
bar: 256,
});
});
it('curries', () => {
const mock1 = {
foo: 128,
bar: 256,
};
const mock2 = {
foo: 256,
qux: 512,
};
const curried = renameKeys({
foo: 'boo',
bar: 'BAR',
});
expect(typeof curried).toEqual('function');
expect(curried(mock1)).toEqual({
boo: 128,
BAR: 256,
});
expect(curried(mock2)).toEqual({
boo: 256,
qux: 512,
});
});
});