// ! API 参考 https://httpbin.org/#/ import { expect, describe, it } from "vitest"; import { Link, fetchRequester, File } from "../../src/index"; Link.registerRequester(fetchRequester); const root = __Root__; describe("资源下载 测试", function () { it("文件下载 测试", async () => { const link = new Link({ url: root + "/stream-bytes/300", }); return link .send() .then(async (res) => res.blob()) .then((res) => { expect(res.size).to.eq(300); }); }); it("文件上传 测试", async () => { const text = Buffer.from("23323"); const link = new Link({ url: root + "/anything", method: "put", body: { type: "binary", data: new File([text], "index.txt"), }, }); return link .send() .then(async (res) => res.json()) .then((res) => { expect(res.data).to.eq(text.toString()); }); }); });