mirror of https://github.com/openclaw/openclaw.git
30 lines
723 B
TypeScript
30 lines
723 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { isPlainObject } from "./plain-object.js";
|
|
|
|
describe("isPlainObject", () => {
|
|
it.each([{}, { a: 1 }, Object.create(null), new (class X {})()])(
|
|
"accepts object-tag values: %j",
|
|
(value) => {
|
|
expect(isPlainObject(value)).toBe(true);
|
|
},
|
|
);
|
|
|
|
it.each([
|
|
null,
|
|
[],
|
|
new Date(),
|
|
/re/,
|
|
"x",
|
|
42,
|
|
() => null,
|
|
new Map(),
|
|
{ [Symbol.toStringTag]: "Array" },
|
|
])("rejects non-plain values: %j", (value) => {
|
|
expect(isPlainObject(value)).toBe(false);
|
|
});
|
|
|
|
it("accepts object-tag values with an explicit Object toStringTag", () => {
|
|
expect(isPlainObject({ [Symbol.toStringTag]: "Object" })).toBe(true);
|
|
});
|
|
});
|