import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { describe, it, expect, beforeEach, afterEach } from "vitest"; import { buildImportUrl } from "./import-url.js";
describe("buildImportUrl", () => {
let tmpDir: string;
let tmpFile: string;
it("returns same URL for bundled hooks across calls (cacheable)", () => { const url1 = buildImportUrl(tmpFile, "openclaw-bundled"); const url2 = buildImportUrl(tmpFile, "openclaw-bundled");
expect(url1).toBe(url2);
});
it("returns same URL for workspace hooks when file is unchanged", () => { const url1 = buildImportUrl(tmpFile, "openclaw-workspace"); const url2 = buildImportUrl(tmpFile, "openclaw-workspace");
expect(url1).toBe(url2);
});
it("falls back to Date.now() when file does not exist", () => { const url = buildImportUrl("/nonexistent/handler.js", "openclaw-workspace");
expect(url).toMatch(/\?t=\d+/);
});
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.