mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 12:26:38 -06:00
test: guard channel loader jiti mock call
This commit is contained in:
@@ -26,6 +26,16 @@ function createTempDir(): string {
|
||||
return tempDir;
|
||||
}
|
||||
|
||||
function requireCreateJitiCall(
|
||||
createJiti: ReturnType<typeof vi.fn>,
|
||||
): [string, { tryNative?: boolean }] {
|
||||
const call = createJiti.mock.calls.at(0);
|
||||
if (!call) {
|
||||
throw new Error("expected createJiti call");
|
||||
}
|
||||
return call as [string, { tryNative?: boolean }];
|
||||
}
|
||||
|
||||
describe("channel plugin module loader helpers", () => {
|
||||
it("resolves extensionless plugin module specifiers to the first existing extension", () => {
|
||||
const rootDir = createTempDir();
|
||||
@@ -102,9 +112,9 @@ describe("channel plugin module loader helpers", () => {
|
||||
target: fs.realpathSync.native(modulePath),
|
||||
});
|
||||
expect(createJiti).toHaveBeenCalledOnce();
|
||||
const [loaderFilename, loaderOptions] = createJiti.mock.calls[0] ?? [];
|
||||
const [loaderFilename, loaderOptions] = requireCreateJitiCall(createJiti);
|
||||
expect(loaderFilename).toContain("module-loader.ts");
|
||||
expect(loaderOptions?.tryNative).toBe(false);
|
||||
expect(loaderOptions.tryNative).toBe(false);
|
||||
expect(loadWithJiti).toHaveBeenCalledWith(fs.realpathSync.native(modulePath));
|
||||
} finally {
|
||||
for (const [extension, hook] of sourceHooks) {
|
||||
|
||||
Reference in New Issue
Block a user