Skip to content

Commit 604c4b1

Browse files
committed
test: remove onUnhandledRequest test
1 parent ddc39fe commit 604c4b1

File tree

1 file changed

+1
-38
lines changed

1 file changed

+1
-38
lines changed

test/unit/deprecation.test.ts

+1-38
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import { createServer } from "http";
21
import { readFileSync } from "fs";
3-
4-
import fetch from "node-fetch";
52
import { sign } from "@octokit/webhooks-methods";
63

7-
import { Webhooks, createNodeMiddleware } from "../../src";
4+
import { Webhooks } from "../../src";
85

96
const pushEventPayloadString = readFileSync(
107
"test/fixtures/push-payload.json",
@@ -18,40 +15,6 @@ describe("Deprecations", () => {
1815
pushEventPayloadString
1916
);
2017
});
21-
test("onUnhandledRequest", async () => {
22-
const spy = jest.spyOn(console, "error");
23-
const webhooks = new Webhooks({
24-
secret: "mySecret",
25-
});
26-
27-
const server = createServer(
28-
createNodeMiddleware(webhooks, {
29-
onUnhandledRequest(_request, response) {
30-
response.writeHead(404);
31-
response.end("nope");
32-
},
33-
})
34-
).listen();
35-
36-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
37-
const { port } = server.address();
38-
39-
await fetch(`http://localhost:${port}/api/github/webhooks`, {
40-
method: "PUT",
41-
headers: {
42-
"X-GitHub-Delivery": "123e4567-e89b-12d3-a456-426655440000",
43-
"X-GitHub-Event": "push",
44-
"X-Hub-Signature-256": signatureSha256,
45-
},
46-
body: "invalid",
47-
});
48-
49-
expect(spy).toBeCalledWith(
50-
"[@octokit/webhooks] `onUnhandledRequest()` is deprecated and will be removed in a future release of `@octokit/webhooks`"
51-
);
52-
spy.mockClear();
53-
server.close();
54-
});
5518

5619
test("webhooks.verify(payload, signature) with object payload", async () => {
5720
const spy = jest.spyOn(console, "error");

0 commit comments

Comments
 (0)