From c2a9ce40ffe244b0c2c45502370229b3632a13c6 Mon Sep 17 00:00:00 2001 From: Atulya Singh Date: Tue, 23 Jun 2026 00:12:50 +0530 Subject: [PATCH] test(core): add isRecord unit tests for json-types --- src/lib/core/json-types.test.ts | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/lib/core/json-types.test.ts diff --git a/src/lib/core/json-types.test.ts b/src/lib/core/json-types.test.ts new file mode 100644 index 00000000000..c4f56e2714e --- /dev/null +++ b/src/lib/core/json-types.test.ts @@ -0,0 +1,44 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { describe, expect, it } from "vitest"; +import { isRecord } from "./json-types"; + +describe("isRecord", () => { + it("returns true for a plain object", () => { + expect(isRecord({ key: "value" })).toBe(true); + }); + + it("returns true for an empty object", () => { + expect(isRecord({})).toBe(true); + }); + + it("returns true for a nested object", () => { + expect(isRecord({ a: { b: 1 } })).toBe(true); + }); + + it("returns false for null", () => { + expect(isRecord(null)).toBe(false); + }); + + it("returns false for undefined", () => { + expect(isRecord(undefined)).toBe(false); + }); + + it("returns false for an array", () => { + expect(isRecord([])).toBe(false); + expect(isRecord([1, 2, 3])).toBe(false); + }); + + it("returns false for a string", () => { + expect(isRecord("hello")).toBe(false); + }); + + it("returns false for a number", () => { + expect(isRecord(42)).toBe(false); + }); + + it("returns false for a boolean", () => { + expect(isRecord(true)).toBe(false); + }); +});