From 0c53565546570219ed0690cb618cfb2ddb70924e Mon Sep 17 00:00:00 2001 From: Kir_Antipov Date: Sat, 6 Jan 2024 10:24:52 +0000 Subject: [PATCH] Tested `getOwnEntries` against arrays --- tests/unit/utils/reflection/object-reflector.spec.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/unit/utils/reflection/object-reflector.spec.ts b/tests/unit/utils/reflection/object-reflector.spec.ts index c413442..6eddab9 100644 --- a/tests/unit/utils/reflection/object-reflector.spec.ts +++ b/tests/unit/utils/reflection/object-reflector.spec.ts @@ -135,7 +135,7 @@ describe("getAllEntries", () => { }); describe("getOwnEntries", () => { - test("returns the key-value pairs from an object", () => { + test("returns the key/value pairs from an object", () => { const obj = { a: 1, b: 2 }; const result = Array.from(getOwnEntries(obj)); @@ -143,7 +143,7 @@ describe("getOwnEntries", () => { expect(result).toEqual([["a", 1], ["b", 2]]); }); - test("returns the key-value pairs from a map", () => { + test("returns the key/value pairs from a map", () => { const map = new Map(Object.entries({ a: 1, b: 2 })); const result = Array.from(getOwnEntries(map)); @@ -151,6 +151,14 @@ describe("getOwnEntries", () => { expect(result).toEqual([["a", 1], ["b", 2]]); }); + test("returns the key/value pairs from an array of key/value pairs", () => { + const entries = [["a", 1], ["b", 2]]; + + const result = Array.from(getOwnEntries(entries)); + + expect(result).toEqual([["a", 1], ["b", 2]]); + }); + test("returns empty array if the object is null or undefined", () => { expect(Array.from(getOwnEntries(null))).toEqual([]); expect(Array.from(getOwnEntries(undefined))).toEqual([]);