Skip to content

Commit

Permalink
No messing with mocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail committed Oct 10, 2024
1 parent cafa983 commit 1c47da8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions tests/http-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ const createHttpsServerSpy = vi
});

export { createHttpsServerSpy, httpsListenSpy, httpListenSpy };
export type HttpServer = http.Server;
export type HttpsServer = https.Server;
12 changes: 6 additions & 6 deletions tests/unit/server.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import http from "node:http";
import https from "node:https";
import { moveRaw } from "../../src/server-helpers";
import { givePort } from "../helpers";
import {
Expand All @@ -13,6 +11,8 @@ import {
createHttpsServerSpy,
httpListenSpy,
httpsListenSpy,
HttpServer,
HttpsServer,
} from "../http-mock";
import { z } from "zod";
import {
Expand Down Expand Up @@ -66,7 +66,7 @@ describe("Server", () => {
);
expect(httpServer).toBeTruthy();
expect(httpsServer).toBeUndefined();
expectTypeOf(httpServer).toMatchTypeOf<http.Server>();
expectTypeOf(httpServer).toMatchTypeOf<HttpServer>();
expectTypeOf(httpsServer).toBeUndefined();
expect(appMock).toBeTruthy();
expect(appMock.disable).toHaveBeenCalledWith("x-powered-by");
Expand Down Expand Up @@ -212,7 +212,7 @@ describe("Server", () => {
expect(httpServer).toBeUndefined();
expect(httpsServer).toBeTruthy();
expectTypeOf(httpServer).toBeUndefined();
expectTypeOf(httpsServer).toMatchTypeOf<https.Server>();
expectTypeOf(httpsServer).toMatchTypeOf<HttpsServer>();
expect(createHttpsServerSpy).toHaveBeenCalledWith(
configMock.https.options,
appMock,
Expand Down Expand Up @@ -241,8 +241,8 @@ describe("Server", () => {
);
expect(httpServer).toBeTruthy();
expect(httpsServer).toBeTruthy();
expectTypeOf(httpServer).toMatchTypeOf<http.Server>();
expectTypeOf(httpsServer).toMatchTypeOf<https.Server>();
expectTypeOf(httpServer).toMatchTypeOf<HttpServer>();
expectTypeOf(httpsServer).toMatchTypeOf<HttpsServer>();
});

test("should enable compression on request", async () => {
Expand Down

0 comments on commit 1c47da8

Please sign in to comment.