()
| 34 | } |
| 35 | |
| 36 | function mockSdk() { |
| 37 | const functions = new Map<string, Function>(); |
| 38 | return { |
| 39 | registerFunction: (idOrOpts: string | { id: string }, handler: Function) => { |
| 40 | const id = typeof idOrOpts === "string" ? idOrOpts : idOrOpts.id; |
| 41 | functions.set(id, handler); |
| 42 | }, |
| 43 | registerTrigger: () => {}, |
| 44 | trigger: async (idOrInput: string | { function_id: string; payload: unknown }, data?: unknown) => { |
| 45 | const id = typeof idOrInput === "string" ? idOrInput : idOrInput.function_id; |
| 46 | const payload = typeof idOrInput === "string" ? data : idOrInput.payload; |
| 47 | const fn = functions.get(id); |
| 48 | if (!fn) throw new Error(`No function: ${id}`); |
| 49 | return fn(payload); |
| 50 | }, |
| 51 | }; |
| 52 | } |
| 53 | |
| 54 | function makeMemory(overrides: Partial<Memory> = {}): Memory { |
| 55 | return { |
no test coverage detected