silverbullet/plug-api/lib/syscall_mock.ts

14 lines
404 B
TypeScript
Raw Permalink Normal View History

2024-10-11 21:52:37 +08:00
import { parse as parseYaml } from "@std/yaml";
2023-07-26 23:12:56 +08:00
2024-07-30 23:24:17 +08:00
// @ts-ignore: syscall is a global function
2023-07-26 23:12:56 +08:00
globalThis.syscall = (name: string, ...args: readonly any[]) => {
switch (name) {
case "yaml.parse":
2024-10-11 21:52:37 +08:00
return Promise.resolve(parseYaml(args[0]));
case "system.applyAttributeExtractors":
return Promise.resolve({});
2023-07-26 23:12:56 +08:00
default:
throw Error(`Not implemented in tests: ${name}`);
}
};