Skip to content

Commit

Permalink
chore(test): remove some ts-expect-error (#1037)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Jul 15, 2024
1 parent 8c4f602 commit 3cdcf89
Showing 1 changed file with 16 additions and 30 deletions.
46 changes: 16 additions & 30 deletions test/integration/node-middleware.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, beforeAll, afterEach, expect, test, vi } from "vitest";
import { createServer } from "node:http";
import { readFileSync } from "node:fs";
import type { AddressInfo } from "node:net";

import { sign } from "@octokit/webhooks-methods";

Expand Down Expand Up @@ -38,8 +39,7 @@ describe("createNodeMiddleware(webhooks)", () => {

const server = createServer(createNodeMiddleware(webhooks)).listen();

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;

const response = await fetch(
`http://localhost:${port}/api/github/webhooks`,
Expand Down Expand Up @@ -83,8 +83,7 @@ describe("createNodeMiddleware(webhooks)", () => {
expect(event.id).toBe("123e4567-e89b-12d3-a456-426655440000");
});

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;

const response = await fetch(
`http://localhost:${port}/api/github/webhooks`,
Expand Down Expand Up @@ -113,8 +112,7 @@ describe("createNodeMiddleware(webhooks)", () => {

const server = createServer(createNodeMiddleware(webhooks)).listen();

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;
const response = await fetch(
`http://localhost:${port}/api/github/webhooks`,
{
Expand Down Expand Up @@ -144,8 +142,7 @@ describe("createNodeMiddleware(webhooks)", () => {

const server = createServer(createNodeMiddleware(webhooks)).listen();

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;
const response = await fetch(
`http://localhost:${port}/api/github/webhooks`,
{
Expand Down Expand Up @@ -174,8 +171,7 @@ describe("createNodeMiddleware(webhooks)", () => {

const server = createServer(createNodeMiddleware(webhooks)).listen();

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;

const payload = '{"name":"invalid"';

Expand Down Expand Up @@ -207,8 +203,7 @@ describe("createNodeMiddleware(webhooks)", () => {

const server = createServer(createNodeMiddleware(webhooks)).listen();

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;

const response = await fetch(
`http://localhost:${port}/api/github/webhooks`,
Expand Down Expand Up @@ -247,8 +242,7 @@ describe("createNodeMiddleware(webhooks)", () => {
}
}).listen();

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;

const response = await fetch(`http://localhost:${port}/foo`, {
method: "PUT",
Expand All @@ -274,8 +268,7 @@ describe("createNodeMiddleware(webhooks)", () => {

const server = createServer(createNodeMiddleware(webhooks)).listen();

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;

const response = await fetch(
`http://localhost:${port}/api/github/webhooks`,
Expand Down Expand Up @@ -311,8 +304,7 @@ describe("createNodeMiddleware(webhooks)", () => {

const server = createServer(createNodeMiddleware(webhooks)).listen();

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;

const response = await fetch(
`http://localhost:${port}/api/github/webhooks`,
Expand Down Expand Up @@ -345,8 +337,7 @@ describe("createNodeMiddleware(webhooks)", () => {

const server = createServer(createNodeMiddleware(webhooks)).listen();

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;

const response = await fetch(
`http://localhost:${port}/api/github/webhooks`,
Expand Down Expand Up @@ -384,8 +375,7 @@ describe("createNodeMiddleware(webhooks)", () => {

const server = createServer(createNodeMiddleware(webhooks)).listen();

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;

const response = await fetch(
`http://localhost:${port}/api/github/webhooks`,
Expand Down Expand Up @@ -420,8 +410,7 @@ describe("createNodeMiddleware(webhooks)", () => {

const server = createServer(createNodeMiddleware(webhooks)).listen();

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;

const response = await fetch(
`http://localhost:${port}/api/github/webhooks`,
Expand Down Expand Up @@ -582,8 +571,7 @@ describe("createNodeMiddleware(webhooks)", () => {
};
const server = createServer(mockedMiddleware).listen();

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;

const response = await fetch(
`http://localhost:${port}/api/github/webhooks`,
Expand Down Expand Up @@ -628,8 +616,7 @@ describe("createNodeMiddleware(webhooks)", () => {
const middleware = createNodeMiddleware(webhooks, { log });
const server = createServer(middleware).listen();

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;

const response = await fetch(
`http://localhost:${port}/api/github/webhooks`,
Expand Down Expand Up @@ -678,8 +665,7 @@ test("request.body is already an Object and has request.rawBody as Buffer (e.g.
expect(event.id).toBe("123e4567-e89b-12d3-a456-426655440000");
});

// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
const { port } = server.address();
const { port } = server.address() as AddressInfo;

const response = await fetch(`http://localhost:${port}/api/github/webhooks`, {
method: "POST",
Expand Down

0 comments on commit 3cdcf89

Please sign in to comment.