Skip to content

Commit

Permalink
fix: fix old
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Jun 22, 2024
1 parent e491f9c commit 0fdc969
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
11 changes: 4 additions & 7 deletions packages/tiny-react/src/hmr/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it, vi } from "vitest";
import { type ViteHot, createManager } from ".";
import { type ViteHot, setupVite } from ".";
import { useEffect, useReducer } from "../hooks";
import { render } from "../reconciler";
import { sleepFrame } from "../test-utils";
Expand Down Expand Up @@ -45,9 +45,8 @@ describe("hmr", () => {
return <div>1</div>;
}

const manager = createManager(hot, runtime, false);
const manager = setupVite(hot, runtime, false);
ChildExport = manager.wrap("Child", Child, "useEffect");
manager.setup();
}

const vnode = <Parent />;
Expand Down Expand Up @@ -78,9 +77,8 @@ describe("hmr", () => {
return <div>2</div>;
}

const manager = createManager(hot, runtime, false);
const manager = setupVite(hot, runtime, false);
manager.wrap("Child", Child, "");
manager.setup();
}

// simulate 1st version's `hot.accept`
Expand Down Expand Up @@ -119,9 +117,8 @@ describe("hmr", () => {
return <div>3</div>;
}

const manager = createManager(hot, runtime, false);
const manager = setupVite(hot, runtime, false);
manager.wrap("Child", Child, "useEffect");
manager.setup();
}

acceptCallbacks[1]({});
Expand Down
17 changes: 6 additions & 11 deletions packages/tiny-refresh/src/runtime.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { act, cleanup, render } from "@testing-library/react";
import React from "react";
import { afterEach, describe, expect, it, vi } from "vitest";
import { type ViteHot, createManager } from "./runtime";
import { type ViteHot, setupVite } from "./runtime";

afterEach(cleanup);

Expand Down Expand Up @@ -37,9 +37,8 @@ describe("hmr", () => {
return <div>1</div>;
}

const manager = createManager(hot, React, false);
const manager = setupVite(hot, React, false);
ChildExport = manager.wrap("Child", Child, "useEffect");
manager.setup();
}

function Parent() {
Expand Down Expand Up @@ -70,9 +69,8 @@ describe("hmr", () => {
function Child() {
return <div>2</div>;
}
const manager = createManager(hot, React, false);
const manager = setupVite(hot, React, false);
manager.wrap("Child", Child, "");
manager.setup();
}

// simulate last version's `hot.accept`
Expand Down Expand Up @@ -111,9 +109,8 @@ describe("hmr", () => {
return <div>3</div>;
}

const manager = createManager(hot, React, false);
const manager = setupVite(hot, React, false);
manager.wrap("Child", Child, "useEffect");
manager.setup();
}

act(() => acceptCallbacks[1]({}));
Expand Down Expand Up @@ -154,9 +151,8 @@ describe("hmr", () => {
return <div>4</div>;
}

const manager = createManager(hot, React, false);
const manager = setupVite(hot, React, false);
manager.wrap("Child", Child, "useEffect");
manager.setup();
}

act(() => acceptCallbacks[1]({}));
Expand Down Expand Up @@ -191,9 +187,8 @@ describe("hmr", () => {
return <div>5</div>;
}

const manager = createManager(hot, React, false);
const manager = setupVite(hot, React, false);
manager.wrap("Child", Child, "");
manager.setup();
}

act(() => acceptCallbacks[1]({}));
Expand Down
2 changes: 1 addition & 1 deletion packages/tiny-refresh/src/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const MANAGER_KEY = Symbol.for("tiny-refresh.manager");

interface ViteHot {
export interface ViteHot {
accept: (onNewModule: (newModule?: unknown) => void) => void;
invalidate: (message?: string) => void;
data: HotData;
Expand Down

0 comments on commit 0fdc969

Please sign in to comment.