mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 23:50:20 +00:00
refactor: share plain object guard across config and utils
This commit is contained in:
18
src/infra/plain-object.test.ts
Normal file
18
src/infra/plain-object.test.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isPlainObject } from "./plain-object.js";
|
||||
|
||||
describe("isPlainObject", () => {
|
||||
it("accepts plain objects", () => {
|
||||
expect(isPlainObject({})).toBe(true);
|
||||
expect(isPlainObject({ a: 1 })).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects non-plain values", () => {
|
||||
expect(isPlainObject(null)).toBe(false);
|
||||
expect(isPlainObject([])).toBe(false);
|
||||
expect(isPlainObject(new Date())).toBe(false);
|
||||
expect(isPlainObject(/re/)).toBe(false);
|
||||
expect(isPlainObject("x")).toBe(false);
|
||||
expect(isPlainObject(42)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user