Skip to content

Commit

Permalink
Fix further fetch assignment issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jpwilliams committed Apr 16, 2024
1 parent e7aeb7b commit c85b9c9
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions packages/inngest/src/components/Inngest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,31 +494,43 @@ 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"
);
});

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");
});
Expand Down

0 comments on commit c85b9c9

Please sign in to comment.