Skip to content

Commit

Permalink
refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
aralroca committed Oct 4, 2023
1 parent 01d295a commit ca87436
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/cli/serve/serve-options.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ import {
afterAll,
} from "bun:test";
import getConstants from "../../constants";
import { Serve, gc } from "bun";
import { GlobalRegistrator } from "@happy-dom/global-registrator";

const ROOT_DIR = path.join(import.meta.dir, "..", "..", "__fixtures__");

const PAGES_DIR = path.join(ROOT_DIR, "pages");
const ASSETS_DIR = path.join(ROOT_DIR, "assets");
let serveOptions: Serve;

function testRequest(request: Request): Response {
async function testRequest(request: Request): Promise<Response> {
const serveOptions = (await import("./serve-options")).serveOptions;

return (
// @ts-ignore
(serveOptions.fetch(request, { requestIP: () => {}, upgrade: () => {} }) ||
(await serveOptions.fetch(request, { requestIP: () => { }, upgrade: () => { } }) ||
new Response()) as Response
);
}
Expand All @@ -47,12 +46,10 @@ describe("CLI: serve", () => {
defaultLocale: "es",
},
};
serveOptions = (await import("./serve-options")).serveOptions;
});

afterEach(() => {
globalThis.mockConstants = undefined;
gc(true);
});

it("should return 404 page", async () => {
Expand Down

0 comments on commit ca87436

Please sign in to comment.