Skip to content

Commit

Permalink
chore: add tests for global headers
Browse files Browse the repository at this point in the history
  • Loading branch information
ytkimirti committed Dec 4, 2024
1 parent 9df1c5e commit a5a1982
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/client/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,45 @@ describe("E2E Publish", () => {
expect(verifiedMessage.maxRetries).toBeGreaterThanOrEqual(retryCount);
expect(verifiedMessage.failureCallback).toBe("https://oz.requestcatcher.com/?foo=bar");
});

test("should use global headers", async () => {
const clientWithHeaders = new Client({
token: process.env.QSTASH_TOKEN!,
headers: {
"test-header": "test-value",
},
});

const result = await clientWithHeaders.publish({
url: "https://example.com/",
});

const verifiedMessage = await client.messages.get(result.messageId);
const messageHeaders = new Headers(verifiedMessage.header);

expect(messageHeaders.get("test-header")).toEqual("test-value");
});

test("should override global headers if headers are provided", async () => {
const clientWithHeaders = new Client({
token: process.env.QSTASH_TOKEN!,
headers: {
"TEST-HEADER": "global-value",
},
});

const result = await clientWithHeaders.publish({
url: "https://example.com/",
headers: {
"Test-Header": "override-value",
},
});

const verifiedMessage = await client.messages.get(result.messageId);
const messageHeaders = new Headers(verifiedMessage.header);

expect(messageHeaders.get("test-header")).toEqual("override-value");
});
});

describe("E2E Url Group Publish", () => {
Expand Down

0 comments on commit a5a1982

Please sign in to comment.