创建 mock Response
(options: {
ok?: boolean;
status?: number;
statusText?: string;
text?: string;
blob?: Blob;
})
| 20 | |
| 21 | /** 创建 mock Response */ |
| 22 | function createMockResponse(options: { |
| 23 | ok?: boolean; |
| 24 | status?: number; |
| 25 | statusText?: string; |
| 26 | text?: string; |
| 27 | blob?: Blob; |
| 28 | }): Response { |
| 29 | const { ok = true, status = 200, statusText = "OK", text = "" } = options; |
| 30 | return { |
| 31 | ok, |
| 32 | status, |
| 33 | statusText, |
| 34 | headers: new Headers(), |
| 35 | text: vi.fn().mockResolvedValue(text), |
| 36 | blob: vi.fn().mockResolvedValue(options.blob ?? new Blob([text])), |
| 37 | } as unknown as Response; |
| 38 | } |
| 39 | |
| 40 | describe("S3FileSystem", () => { |
| 41 | let mockClient: S3Client; |