|
1 |
| -import { describe, expect, it, vi } from "vitest"; |
| 1 | +import { describe, expect, it } from "vitest"; |
2 | 2 | import { createSha256, pruneObject } from "./helpers";
|
3 | 3 | import { initServerFetcher } from "./server";
|
4 | 4 | import { TypedDocumentString } from "./testing";
|
@@ -52,7 +52,6 @@ describe("gqlServerFetch", () => {
|
52 | 52 | }),
|
53 | 53 | cache: "force-cache",
|
54 | 54 | next: { revalidate: 900 },
|
55 |
| - signal: expect.any(AbortSignal), |
56 | 55 | },
|
57 | 56 | );
|
58 | 57 | });
|
@@ -93,7 +92,6 @@ describe("gqlServerFetch", () => {
|
93 | 92 | "Content-Type": "application/json",
|
94 | 93 | }),
|
95 | 94 | next: { revalidate: 900 },
|
96 |
| - signal: expect.any(AbortSignal), |
97 | 95 | },
|
98 | 96 | );
|
99 | 97 | });
|
@@ -131,7 +129,6 @@ describe("gqlServerFetch", () => {
|
131 | 129 | "Content-Type": "application/json",
|
132 | 130 | }),
|
133 | 131 | next: { revalidate: 900 },
|
134 |
| - signal: expect.any(AbortSignal), |
135 | 132 | },
|
136 | 133 | );
|
137 | 134 | });
|
@@ -164,7 +161,6 @@ describe("gqlServerFetch", () => {
|
164 | 161 | }),
|
165 | 162 | cache: "no-store",
|
166 | 163 | next: { revalidate: undefined },
|
167 |
| - signal: expect.any(AbortSignal), |
168 | 164 | },
|
169 | 165 | );
|
170 | 166 | });
|
@@ -203,7 +199,6 @@ describe("gqlServerFetch", () => {
|
203 | 199 | }),
|
204 | 200 | cache: "force-cache",
|
205 | 201 | next: { revalidate: 900 },
|
206 |
| - signal: expect.any(AbortSignal), |
207 | 202 | },
|
208 | 203 | );
|
209 | 204 | });
|
@@ -234,7 +229,6 @@ describe("gqlServerFetch", () => {
|
234 | 229 | "Content-Type": "application/json",
|
235 | 230 | }),
|
236 | 231 | cache: "no-store",
|
237 |
| - signal: expect.any(AbortSignal), |
238 | 232 | },
|
239 | 233 | );
|
240 | 234 | });
|
@@ -264,41 +258,8 @@ describe("gqlServerFetch", () => {
|
264 | 258 | expect(fetchMock).toHaveBeenCalledTimes(1);
|
265 | 259 | });
|
266 | 260 |
|
267 |
| - it("should use time out after 30 seconds by default", async () => { |
268 |
| - const timeoutSpy = vi.spyOn(AbortSignal, "timeout"); |
269 |
| - const gqlServerFetch = initServerFetcher("https://localhost/graphql"); |
270 |
| - fetchMock.mockResponse(successResponse); |
271 |
| - |
272 |
| - await gqlServerFetch(query, { myVar: "baz" }, {}); |
273 |
| - |
274 |
| - expect(timeoutSpy).toHaveBeenCalledWith(30000); |
275 |
| - |
276 |
| - // It should not try to POST the query if the persisted query cannot be parsed |
277 |
| - expect(fetchMock).toHaveBeenCalledTimes(1); |
278 |
| - }); |
279 |
| - |
280 |
| - it("should use the provided timeout duration", async () => { |
281 |
| - vi.useFakeTimers(); |
282 |
| - const timeoutSpy = vi.spyOn(AbortSignal, "timeout"); |
283 |
| - const gqlServerFetch = initServerFetcher("https://localhost/graphql", { |
284 |
| - defaultTimeout: 1, |
285 |
| - }); |
286 |
| - fetchMock.mockResponse(successResponse); |
287 |
| - |
288 |
| - await gqlServerFetch(query, { myVar: "baz" }, {}); |
289 |
| - |
290 |
| - vi.runAllTimers(); |
291 |
| - |
292 |
| - expect(timeoutSpy).toHaveBeenCalledWith(1); |
293 |
| - |
294 |
| - // It should not try to POST the query if the persisted query cannot be parsed |
295 |
| - expect(fetchMock).toHaveBeenCalledTimes(1); |
296 |
| - }); |
297 |
| - |
298 | 261 | it("should use the provided signal", async () => {
|
299 |
| - const gqlServerFetch = initServerFetcher("https://localhost/graphql", { |
300 |
| - defaultTimeout: 1, |
301 |
| - }); |
| 262 | + const gqlServerFetch = initServerFetcher("https://localhost/graphql"); |
302 | 263 | fetchMock.mockResponse(successResponse);
|
303 | 264 |
|
304 | 265 | const controller = new AbortController();
|
|
0 commit comments