diff --git a/src/common/k8s-api/__tests__/kube-api.test.ts b/src/common/k8s-api/__tests__/kube-api.test.ts index 108f58d173..474c876d36 100644 --- a/src/common/k8s-api/__tests__/kube-api.test.ts +++ b/src/common/k8s-api/__tests__/kube-api.test.ts @@ -21,7 +21,8 @@ import { flushPromises } from "../../test-utils/flush-promises"; import createKubeJsonApiInjectable from "../create-kube-json-api.injectable"; import type { IKubeWatchEvent } from "../kube-watch-event"; import type { KubeJsonApiDataFor } from "../kube-object"; -import type { Response, Headers as NodeFetchHeaders } from "node-fetch"; +import { Headers as NodeFetchHeaders } from "node-fetch"; +import type { Response } from "node-fetch"; import AbortController from "abort-controller"; const createMockResponseFromString = (url: string, data: string, statusCode = 200) => { @@ -32,8 +33,7 @@ const createMockResponseFromString = (url: string, data: string, statusCode = 20 blob: jest.fn(async () => { throw new Error("blob() is not supported"); }), body: new PassThrough(), bodyUsed: false, - formData: jest.fn(async () => { throw new Error("formData() is not supported"); }), - headers: new Headers() as NodeFetchHeaders, + headers: new NodeFetchHeaders(), json: jest.fn(async () => JSON.parse(await res.text())), ok: 200 <= statusCode && statusCode < 300, redirected: 300 <= statusCode && statusCode < 400, @@ -43,6 +43,8 @@ const createMockResponseFromString = (url: string, data: string, statusCode = 20 text: jest.fn(async () => data), type: "basic", url, + textConverted: jest.fn(async () => { throw new Error("textConverted() is not supported"); }), + timeout: 0, }; return res; @@ -56,8 +58,7 @@ const createMockResponseFromStream = (url: string, stream: NodeJS.ReadableStream blob: jest.fn(async () => { throw new Error("blob() is not supported"); }), body: stream, bodyUsed: false, - formData: jest.fn(async () => { throw new Error("formData() is not supported"); }), - headers: new Headers() as NodeFetchHeaders, + headers: new NodeFetchHeaders(), json: jest.fn(async () => JSON.parse(await res.text())), ok: 200 <= statusCode && statusCode < 300, redirected: 300 <= statusCode && statusCode < 400, @@ -75,6 +76,8 @@ const createMockResponseFromStream = (url: string, stream: NodeJS.ReadableStream }), type: "basic", url, + textConverted: jest.fn(async () => { throw new Error("textConverted() is not supported"); }), + timeout: 0, }; return res;