From af29b598b4031b37f4eb806e52abbbbeaf517b5f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 14 Feb 2023 23:42:37 +0100 Subject: [PATCH] test(simulator): add hasOwnProp() tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- test/utils/UtilsTest.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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); -- 2.34.1