test(simulator): add hasOwnProp() tests
[e-mobility-charging-stations-simulator.git] / test / utils / UtilsTest.ts
index 401e5e6d231eae8c30e683da046b1dfa60e31b27..dcdf78962e585080084c495471dd3582376f797b 100644 (file)
@@ -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);