(name: string, dir: Map<string, any>)
| 15 | } |
| 16 | |
| 17 | function createMockFileHandle(name: string, dir: Map<string, any>) { |
| 18 | return { |
| 19 | kind: "file" as const, |
| 20 | getFile: vi.fn(async () => { |
| 21 | const content = dir.get(name); |
| 22 | if (content instanceof Blob) return content; |
| 23 | if (content instanceof ArrayBuffer) return new Blob([content]); |
| 24 | if (content instanceof Uint8Array) return new Blob([content.buffer as ArrayBuffer]); |
| 25 | if (typeof content === "string") return new Blob([content], { type: "application/octet-stream" }); |
| 26 | return new Blob([""], { type: "application/octet-stream" }); |
| 27 | }), |
| 28 | createWritable: vi.fn(async () => { |
| 29 | const writable = createMockWritable(); |
| 30 | const origClose = writable.close; |
| 31 | writable.close = vi.fn(async () => { |
| 32 | const written = writable.getData(); |
| 33 | dir.set(name, written); |
| 34 | await origClose(); |
| 35 | }); |
| 36 | return writable; |
| 37 | }), |
| 38 | }; |
| 39 | } |
| 40 | |
| 41 | function createMockDirHandle(store: Map<string, any>): any { |
| 42 | return { |
no test coverage detected