Fix failing tests
This commit is contained in:
@@ -3,25 +3,25 @@ import handleHmr from "../../../../src/functions/server/handle-hmr";
|
||||
|
||||
describe("handle-hmr", () => {
|
||||
beforeEach(() => {
|
||||
global.ROUTER = {
|
||||
global.BUNEXT_ROUTER = {
|
||||
match: (path: string) => {
|
||||
if (path === "/test") return { filePath: "/test-file" };
|
||||
return null;
|
||||
}
|
||||
} as any;
|
||||
global.HMR_CONTROLLERS = [];
|
||||
global.BUNDLER_CTX_MAP = {
|
||||
"/test-file": { local_path: "/test-file" } as any,
|
||||
global.BUNEXT_HMR_CONTROLLERS = [];
|
||||
global.BUNEXT_BUNDLER_CTX_MAP = {
|
||||
"test-file": { local_path: "/test-file" } as any,
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
global.ROUTER = undefined as any;
|
||||
global.HMR_CONTROLLERS = [];
|
||||
global.BUNDLER_CTX_MAP = undefined as any;
|
||||
global.BUNEXT_ROUTER = undefined as any;
|
||||
global.BUNEXT_HMR_CONTROLLERS = [];
|
||||
global.BUNEXT_BUNDLER_CTX_MAP = undefined as any;
|
||||
});
|
||||
|
||||
test("sets up SSE stream and pushes to HMR_CONTROLLERS", async () => {
|
||||
test("sets up SSE stream and pushes to BUNEXT_HMR_CONTROLLERS", async () => {
|
||||
const req = new Request("http://localhost/hmr", {
|
||||
headers: {
|
||||
"referer": "http://localhost/test"
|
||||
@@ -34,8 +34,8 @@ describe("handle-hmr", () => {
|
||||
expect(res.headers.get("Content-Type")).toBe("text/event-stream");
|
||||
expect(res.headers.get("Connection")).toBe("keep-alive");
|
||||
|
||||
expect(global.HMR_CONTROLLERS.length).toBe(1);
|
||||
const controller = global.HMR_CONTROLLERS[0];
|
||||
expect(global.BUNEXT_HMR_CONTROLLERS.length).toBe(1);
|
||||
const controller = global.BUNEXT_HMR_CONTROLLERS[0];
|
||||
expect(controller.page_url).toBe("http://localhost/test");
|
||||
expect(controller.target_map?.local_path).toBe("/test-file");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user