Support Date
Closed this issue · 0 comments
NotFounds commented
Describe the bug
camelizeDeep doesn't support a Date object.
Steps to Reproduce
The following test is failed. camelizeDeep converts a Date instance to empty object.
// date_test.ts
import { assertEquals } from "https://deno.land/std@0.127.0/testing/asserts.ts";
import { camelizeDeep } from "./mod.ts";
Deno.test("camelizeDeep: Object with Date instance", () => {
assertEquals(
camelizeDeep({
id: "test_123",
created_at: new Date("2022-01-31T12:00:00.000"),
}),
{
id: "test_123",
createdAt: new Date("2022-01-31T12:00:00.000"),
},
);
});
~/P/ts-camelize ❯❯❯ deno test date_test.ts
Check file:///Users/ioriikeda/Projects/ts-camelize/date_test.ts
running 1 test from file:///Users/ioriikeda/Projects/ts-camelize/date_test.ts
test camelizeDeep: Object with Date instance ... FAILED (15ms)
failures:
camelizeDeep: Object with Date instance
AssertionError: Values are not equal:
[Diff] Actual / Expected
{
- createdAt: {},
- id: "test123",
+ createdAt: 2022-01-31T03:00:00.000Z,
+ id: "test_123",
}
at assertEquals (https://deno.land/std@0.127.0/testing/asserts.ts:269:9)
at file:///Users/ioriikeda/Projects/ts-camelize/date_test.ts:7:3
at testStepSanitizer (deno:runtime/js/40_testing.js:432:13)
at asyncOpSanitizer (deno:runtime/js/40_testing.js:145:15)
at resourceSanitizer (deno:runtime/js/40_testing.js:360:13)
at Object.exitSanitizer [as fn] (deno:runtime/js/40_testing.js:415:15)
at runTest (deno:runtime/js/40_testing.js:673:18)
at Object.runTests (deno:runtime/js/40_testing.js:786:28)
at [deno:cli/tools/test.rs:512:6]:1:21
failures:
camelizeDeep: Object with Date instance
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out (42ms)
error: Test failed
Expected behavior
camelizeDeep should support Date