Right rail template
This commit is contained in:
+9
-4
@@ -1,4 +1,5 @@
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import type React from "react";
|
||||
import { afterAll, afterEach, beforeAll, vi } from "vitest";
|
||||
import { cleanup } from "@testing-library/react";
|
||||
import { server } from "./tests/msw/server";
|
||||
@@ -11,15 +12,19 @@ import { server } from "./tests/msw/server";
|
||||
vi.mock("next/dynamic", () => {
|
||||
const React = require("react");
|
||||
return {
|
||||
default: (importFn: () => Promise<any>, options?: any) => {
|
||||
default: (
|
||||
importFn: () => Promise<{ default?: React.ComponentType }>,
|
||||
options?: { loading?: () => React.ReactNode },
|
||||
) => {
|
||||
// In tests, return a component that immediately resolves and renders
|
||||
return function DynamicComponent(props: any) {
|
||||
const [Component, setComponent] = React.useState(null);
|
||||
return function DynamicComponent(props: Record<string, unknown>) {
|
||||
const [Component, setComponent] =
|
||||
React.useState<React.ComponentType | null>(null);
|
||||
const [loading, setLoading] = React.useState(true);
|
||||
|
||||
React.useEffect(() => {
|
||||
importFn()
|
||||
.then((mod: any) => {
|
||||
.then((mod: { default?: React.ComponentType }) => {
|
||||
setComponent(mod.default || mod);
|
||||
setLoading(false);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user