forked from ChainLearnOfficial/chainlearn-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch11.js
More file actions
16 lines (15 loc) · 666 Bytes
/
Copy pathpatch11.js
File metadata and controls
16 lines (15 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const fs = require('fs');
const files = [
'src/components/layout/mobile-nav.test.tsx',
'src/components/layout/sidebar.test.tsx'
];
for (const file of files) {
let code = fs.readFileSync(file, 'utf8');
if (!code.includes('vi.mock("next/navigation"')) {
code = code.replace(
/import \{ render, screen \} from "@testing-library\/react";/,
`import { render, screen } from "@testing-library/react";\nimport { vi } from "vitest";\n\nvi.mock("next/navigation", () => ({\n usePathname: () => "/dashboard",\n useRouter: () => ({ push: vi.fn() }),\n useSearchParams: () => new URLSearchParams(),\n}));`
);
}
fs.writeFileSync(file, code);
}