From c85b9c989f76a8d2e1853158e0298f645079aae4 Mon Sep 17 00:00:00 2001 From: Jack Williams <1736957+jpwilliams@users.noreply.github.com> Date: Tue, 16 Apr 2024 12:50:11 +0000 Subject: [PATCH] Fix further fetch assignment issues --- .../inngest/src/components/Inngest.test.ts | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/inngest/src/components/Inngest.test.ts b/packages/inngest/src/components/Inngest.test.ts index 6bd977c69..ba2cb3be4 100644 --- a/packages/inngest/src/components/Inngest.test.ts +++ b/packages/inngest/src/components/Inngest.test.ts @@ -494,22 +494,31 @@ describe("send", () => { }); test("should return error from Inngest if parsed", () => { - global.fetch = setFetch({ status: 400, error: "Test Error" }); - const inngest = createClient({ id: "test", eventKey: testEventKey }); + const inngest = createClient({ + id: "test", + eventKey: testEventKey, + fetch: setFetch({ status: 400, error: "Test Error" }), + }); return expect(inngest.send(testEvent)).rejects.toThrowError("Test Error"); }); test("should return error from Inngest if parsed even for 200", () => { - global.fetch = setFetch({ status: 200, error: "Test Error" }); - const inngest = createClient({ id: "test", eventKey: testEventKey }); + const inngest = createClient({ + id: "test", + eventKey: testEventKey, + fetch: setFetch({ status: 200, error: "Test Error" }), + }); return expect(inngest.send(testEvent)).rejects.toThrowError("Test Error"); }); test("should return error if bad status code with no error string", () => { - global.fetch = setFetch({ status: 400 }); - const inngest = createClient({ id: "test", eventKey: testEventKey }); + const inngest = createClient({ + id: "test", + eventKey: testEventKey, + fetch: setFetch({ status: 400 }), + }); return expect(inngest.send(testEvent)).rejects.toThrowError( "Cannot process event payload" @@ -517,8 +526,11 @@ describe("send", () => { }); test("should return unknown error from response text if very bad status code", () => { - global.fetch = setFetch({ status: 600 }); - const inngest = createClient({ id: "test", eventKey: testEventKey }); + const inngest = createClient({ + id: "test", + eventKey: testEventKey, + fetch: setFetch({ status: 600 }), + }); return expect(inngest.send(testEvent)).rejects.toThrowError("600"); });