mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 18:51:04 +00:00
22 lines
889 B
TypeScript
22 lines
889 B
TypeScript
import { readFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { asNullableRecord, asOptionalRecord } from "./record-coerce.js";
|
|
|
|
describe("record-coerce", () => {
|
|
it("keeps record coercion behavior for optional and nullable variants", () => {
|
|
expect(asOptionalRecord({ ok: true })).toEqual({ ok: true });
|
|
expect(asOptionalRecord(null)).toBeUndefined();
|
|
expect(asOptionalRecord([{ ok: true }])).toBeUndefined();
|
|
expect(asNullableRecord({ ok: true })).toEqual({ ok: true });
|
|
expect(asNullableRecord(null)).toBeNull();
|
|
expect(asNullableRecord([{ ok: true }])).toBeNull();
|
|
});
|
|
|
|
it("stays isolated from utils.ts so browser bundles stay Node-free", () => {
|
|
const source = readFileSync(path.resolve("src/shared/record-coerce.ts"), "utf8");
|
|
|
|
expect(source).not.toContain("../utils.js");
|
|
});
|
|
});
|