forked from ChainLearnOfficial/chainlearn-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch9.js
More file actions
24 lines (23 loc) · 911 Bytes
/
Copy pathpatch9.js
File metadata and controls
24 lines (23 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const fs = require('fs');
const files = ['src/tests/layout/mobile-nav.test.tsx', 'src/tests/layout/sidebar.test.tsx'];
for (const file of files) {
let code = fs.readFileSync(file, 'utf8');
if (!code.includes('useAuthStore')) {
code = code.replace(
/import \{ render, screen \} from "@testing-library\/react";/,
`import { render, screen } from "@testing-library/react";\nimport { useAuthStore } from "@/store/auth-store";`
);
}
if (!code.includes('beforeEach')) {
code = code.replace(
/describe\(".*", \(\) => \{/,
`describe("Nav", () => {\n beforeEach(() => {\n useAuthStore.setState({ isAuthenticated: true, hasHydrated: true });\n });\n`
);
} else {
code = code.replace(
/beforeEach\(\(\) => \{/,
`beforeEach(() => {\n useAuthStore.setState({ isAuthenticated: true, hasHydrated: true });`
);
}
fs.writeFileSync(file, code);
}