Skip to content

Commit 7d3b68c

Browse files
committed
fix: mock request
1 parent 5990e9f commit 7d3b68c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/serve/serve.test.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-unused-vars */
22
/* eslint-disable @typescript-eslint/require-await */
3-
import { describe, expect, spyOn, test } from "bun:test";
3+
import { describe, expect, jest, spyOn, test } from "bun:test";
44
import { serve } from ".";
55
import {
66
driveWorkflow,
@@ -133,9 +133,9 @@ describe("serve", () => {
133133
execute: async (initialPayload, steps, first) => {
134134
const request = first
135135
? new Request(WORKFLOW_ENDPOINT, {
136-
body: JSON.stringify(initialPayload),
137-
method: "POST",
138-
})
136+
body: JSON.stringify(initialPayload),
137+
method: "POST",
138+
})
139139
: getRequest(WORKFLOW_ENDPOINT, workflowRunId, initialPayload, steps);
140140

141141
request.headers.set(WORKFLOW_INVOKE_COUNT_HEADER, "2");
@@ -1017,10 +1017,17 @@ describe("serve", () => {
10171017

10181018
describe("incorrect url will throw", () => {
10191019
const qstashClient = new Client({ token: process.env.QSTASH_TOKEN! });
1020+
1021+
qstashClient.publish = jest.fn().mockImplementation(() => {
1022+
return {
1023+
messageId: "some-message-id",
1024+
deduplicationId: "some-deduplication-id",
1025+
};
1026+
});
10201027
const client = new WorkflowClient({ token: process.env.QSTASH_TOKEN! });
10211028

10221029
test("allow http://", async () => {
1023-
const url = "http://requestcatcher.com";
1030+
const url = "http://some-website.com";
10241031
const { handler } = serve(
10251032
async (context) => {
10261033
await context.sleep("sleeping", 1);

0 commit comments

Comments
 (0)