From a50b694ad460c23b8f35542b6609b226768da675 Mon Sep 17 00:00:00 2001 From: "A.L" Date: Mon, 14 Nov 2022 17:00:44 +0000 Subject: [PATCH] add spec utils/object/removeUndefinedProperties --- tests/utils/object.spec.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/utils/object.spec.ts diff --git a/tests/utils/object.spec.ts b/tests/utils/object.spec.ts new file mode 100644 index 000000000..97bd27eab --- /dev/null +++ b/tests/utils/object.spec.ts @@ -0,0 +1,27 @@ +import { expect } from 'chai'; +import { removeUndefinedProperties } from '../../src/utils/object'; + +describe('Object', () => { + describe('removeUndefinedProperties', () => { + it('should remove all `undefined` properties of a nested object', () => { + const mockObject = { + a : true, + b : undefined, + c : { + a : 0, + b : undefined, + } + }; + const expectedResult = { + a : true, + c : { + a: 0 + } + }; + + removeUndefinedProperties(mockObject); + + expect(mockObject).to.deep.equal(expectedResult); + }); + }); +}); \ No newline at end of file