Tested getOwnEntries against arrays

This commit is contained in:
Kir_Antipov 2024-01-06 10:24:52 +00:00
parent 5c75c036c0
commit 0c53565546

View file

@ -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([]);