Skip to content

Commit f8dcd0f

Browse files
committed
作为独立PR,先退回 PR 1405 的单元测试
1 parent 419178e commit f8dcd0f

1 file changed

Lines changed: 0 additions & 51 deletions

File tree

packages/filesystem/onedrive/onedrive.test.ts

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -280,55 +280,4 @@ describe("OneDriveFileSystem", () => {
280280
});
281281
}
282282
});
283-
284-
it("writer should upload empty string with simple PUT", async () => {
285-
const fs = new OneDriveFileSystem("/", "token");
286-
const requestSpy = vi.spyOn(fs, "request").mockResolvedValue({});
287-
288-
const writer = await fs.create("empty.txt");
289-
await writer.write("");
290-
291-
expect(requestSpy).toHaveBeenCalledTimes(1);
292-
expect(requestSpy.mock.calls[0][0]).toBe(
293-
"https://graph.microsoft.com/v1.0/me/drive/special/approot:/empty.txt:/content"
294-
);
295-
expect(requestSpy.mock.calls[0][1]).toMatchObject({
296-
method: "PUT",
297-
body: "",
298-
});
299-
});
300-
301-
it("writer should upload empty Blob with simple PUT", async () => {
302-
const fs = new OneDriveFileSystem("/", "token");
303-
const requestSpy = vi.spyOn(fs, "request").mockResolvedValue({});
304-
const emptyBlob = new Blob([]);
305-
306-
const writer = await fs.create("empty.bin");
307-
await writer.write(emptyBlob);
308-
309-
expect(requestSpy).toHaveBeenCalledTimes(1);
310-
expect(requestSpy.mock.calls[0][0]).toBe(
311-
"https://graph.microsoft.com/v1.0/me/drive/special/approot:/empty.bin:/content"
312-
);
313-
expect((requestSpy.mock.calls[0][1] as RequestInit).body).toBe(emptyBlob);
314-
});
315-
316-
it("writer should keep upload session for non-empty content", async () => {
317-
const fs = new OneDriveFileSystem("/", "token");
318-
const requestSpy = vi
319-
.spyOn(fs, "request")
320-
.mockResolvedValueOnce({ uploadUrl: "https://upload.example/session" })
321-
.mockResolvedValueOnce({});
322-
323-
const writer = await fs.create("not-empty.txt");
324-
await writer.write("abc");
325-
326-
expect(requestSpy).toHaveBeenCalledTimes(2);
327-
expect(requestSpy.mock.calls[0][0]).toBe(
328-
"https://graph.microsoft.com/v1.0/me/drive/special/approot:/not-empty.txt:/createUploadSession"
329-
);
330-
expect(requestSpy.mock.calls[1][0]).toBe("https://upload.example/session");
331-
const headers = (requestSpy.mock.calls[1][1] as RequestInit).headers as Headers;
332-
expect(headers.get("Content-Range")).toBe("bytes 0-2/3");
333-
});
334283
});

0 commit comments

Comments
 (0)