From: Jérôme Benoit Date: Tue, 14 Feb 2023 22:42:37 +0000 (+0100) Subject: test(simulator): add hasOwnProp() tests X-Git-Tag: v1.1.95~51 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=af29b598b4031b37f4eb806e52abbbbeaf517b5f;p=e-mobility-charging-stations-simulator.git test(simulator): add hasOwnProp() tests Signed-off-by: Jérôme Benoit --- diff --git a/test/utils/UtilsTest.ts b/test/utils/UtilsTest.ts index 401e5e6d..dcdf7896 100644 --- a/test/utils/UtilsTest.ts +++ b/test/utils/UtilsTest.ts @@ -166,6 +166,18 @@ describe('Utils test suite', () => { expect(Utils.isObject(new WeakSet())).toBe(true); }); + it('Verify hasOwnProp()', () => { + expect(Utils.hasOwnProp('test', '')).toBe(false); + expect(Utils.hasOwnProp(undefined, '')).toBe(false); + expect(Utils.hasOwnProp(null, '')).toBe(false); + expect(Utils.hasOwnProp([], '')).toBe(false); + expect(Utils.hasOwnProp({}, '')).toBe(false); + expect(Utils.hasOwnProp({ 1: 1 }, 1)).toBe(true); + expect(Utils.hasOwnProp({ 1: 1 }, 2)).toBe(false); + expect(Utils.hasOwnProp({ '1': '1' }, '1')).toBe(true); + expect(Utils.hasOwnProp({ '1': '1' }, '2')).toBe(false); + }); + it('Verify isIterable()', () => { expect(Utils.isIterable('')).toBe(true); expect(Utils.isIterable(' ')).toBe(true);