// ! API 参考 https://httpbin.org/#/ import { expect, describe, it as IT } from "vitest"; import { Link, randomUA } from "../../src/index"; // Link.registerRequester(fetchRequester); const isBrowser = globalThis === globalThis.window; let it = isBrowser ? IT.skip : IT; const root = __Root__; describe("随机 UA 测试", function () { it("randomUA 测试", async () => { const link = new Link({ url: root + "/user-agent", }); const ua: string[] = []; await link .use(randomUA()) .send() .then(async (res) => res.json()) .then((res) => { ua.push(res["user-agent"]); }); await link .use(randomUA()) .send() .then(async (res) => res.json()) .then((res) => { ua.push(res["user-agent"]); }); expect(new Set(ua).size).to.eq(ua.length); }); });