Tidy ADR27 test

This commit is contained in:
willclarktech 2020-08-11 13:07:15 +02:00
parent d0ff5fabca
commit c25fe02413
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7
2 changed files with 5 additions and 5 deletions

View File

@ -25,7 +25,7 @@ describe("adr27", () => {
expect(omitDefault(0.0)).toEqual(null);
});
it("works for repeaded", () => {
it("works for repeated", () => {
expect(omitDefault(["a", "b", "c"])).toEqual(["a", "b", "c"]);
expect(omitDefault([])).toEqual(null);
});
@ -69,7 +69,7 @@ describe("adr27", () => {
expect(omitDefaults(0.0)).toEqual(null);
});
it("works for repeaded", () => {
it("works for repeated", () => {
expect(omitDefaults(["a", "b", "c"])).toEqual(["a", "b", "c"]);
expect(omitDefaults([])).toEqual(null);
});

View File

@ -41,10 +41,10 @@ export function omitDefaults(input: any): any {
// Object
if (isNonNullObject(input)) {
return Object.keys(input).reduce(
(accumulator, key) => ({
return Object.entries(input).reduce(
(accumulator, [key, value]) => ({
...accumulator,
[key]: omitDefaults((input as any)[key]),
[key]: omitDefaults(value),
}),
{},
);