OpenPanel/packages/hasura/test/utils/camelizaKeys.spec.ts

30 lines
779 B
TypeScript
Raw Normal View History

2024-05-08 17:58:53 +00:00
import { camelizeKeys } from "../../src/utils";
describe("camelizeKeys", () => {
it("should return undefined if the input is undefined", () => {
const result = camelizeKeys(undefined);
expect(result).toBeUndefined();
});
it("should return an object with camelCase keys", () => {
const input = {
first_key: "value1",
second_key: "value2",
third_key: {
inner_key: "value3",
},
};
const expectedResult = {
firstKey: "value1",
secondKey: "value2",
thirdKey: {
inner_key: "value3",
},
};
const result = camelizeKeys(input);
expect(result).toEqual(expectedResult);
});
});