From 9d0a05672b9af62e051dd99d87f110198029a728 Mon Sep 17 00:00:00 2001 From: Edmund Hung Date: Mon, 6 Jan 2025 20:39:40 +0000 Subject: [PATCH] add one more test for multiple keys --- .../misc/test/fetch-mock.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fixtures/vitest-pool-workers-examples/misc/test/fetch-mock.test.ts b/fixtures/vitest-pool-workers-examples/misc/test/fetch-mock.test.ts index 669c68aa4406..4db01193ecca 100644 --- a/fixtures/vitest-pool-workers-examples/misc/test/fetch-mock.test.ts +++ b/fixtures/vitest-pool-workers-examples/misc/test/fetch-mock.test.ts @@ -43,6 +43,11 @@ it("intercepts URLs with query parameters with repeated keys", async () => { .intercept({ path: "/bar?a=1&a=2" }) .reply(200, "bar"); + fetchMock + .get("https://example.com") + .intercept({ path: "/baz", query: { key1: ["a", "b"], key2: "c" } }) + .reply(200, "baz"); + let response1 = await fetch("https://example.com/foo?key=value"); expect(response1.url).toEqual("https://example.com/foo?key=value"); expect(await response1.text()).toBe("foo"); @@ -50,6 +55,10 @@ it("intercepts URLs with query parameters with repeated keys", async () => { let response2 = await fetch("https://example.com/bar?a=1&a=2"); expect(response2.url).toEqual("https://example.com/bar?a=1&a=2"); expect(await response2.text()).toBe("bar"); + + let response3 = await fetch("https://example.com/baz?key1=a&key2=c&key1=b"); + expect(response3.url).toEqual("https://example.com/baz?key1=a&key2=c&key1=b"); + expect(await response3.text()).toBe("baz"); }); describe("AbortSignal", () => {