Skip to content

Commit

Permalink
Update tests to work with fetch-mock 11
Browse files Browse the repository at this point in the history
  • Loading branch information
vierbergenlars committed Oct 18, 2024
1 parent 05a34fc commit 55ff4b4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions packages/fetch-hooks/__tests__/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { appendHeader } from '../src/request';

test("compose", async () => {
const fakeFetch = fetchMock.sandbox();
global.Request = fakeFetch.config.Request as any;

const testHeader = "X-Test";

Expand All @@ -29,7 +28,7 @@ test("compose", async () => {

expect(response.ok).toBe(true);
expect(await response.json()).toEqual({
test: "1,2,3"
test: "1, 2, 3"
})

})
6 changes: 3 additions & 3 deletions packages/fetch-hooks/__tests__/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { DuplicateInvocationError, FetchHookInvocationImpl } from '../src/hook/i

describe("hook", () => {
const fakeFetch = fetchMock.sandbox();
global.Request = fakeFetch.config.Request as any;

fakeFetch.post("http://localhost/length", async (_url, {headers, body}) => {
const h = new Headers(headers)
Expand Down Expand Up @@ -71,8 +70,9 @@ describe("hook", () => {
"X-Loopback": "true"
},
method: "POST",
body: request.body
})
body: request.body,
duplex: "half" // This is required when a stream is sent, but it is not part of the types yet
} as unknown as RequestInit)
return next(newRequest);
});

Expand Down
1 change: 0 additions & 1 deletion packages/fetch-hooks/__tests__/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { setHeader } from '../src/request';

describe("setHeader", () => {
const fakeFetch = fetchMock.sandbox();
global.Request = fakeFetch.config.Request as any;

const testHeader = "X-Test";

Expand Down

0 comments on commit 55ff4b4

Please sign in to comment.