|
5 | 5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause |
6 | 6 | */ |
7 | 7 | import * as path from 'node:path'; |
8 | | -import { processTemplate, getModulesDirs } from '../baseContext'; |
| 8 | +import { getModulesDirs } from '../baseContext'; |
9 | 9 | import '../../jest/matchers'; |
10 | 10 | import { FileSystemDataProvider } from '../providers/fileSystemDataProvider'; |
11 | 11 | import { normalizePath } from '../utils'; |
@@ -35,62 +35,6 @@ const CORE_WORKSPACE_PATH = normalizePath( |
35 | 35 | ); |
36 | 36 |
|
37 | 37 | // Mock JSON imports using fs.readFileSync since Jest cannot directly import JSON files |
38 | | -jest.mock('../resources/core/jsconfig-core.json', () => { |
39 | | - // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment |
40 | | - const fs = require('node:fs'); |
41 | | - // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment |
42 | | - const pathModule = require('node:path'); |
43 | | - // Always read from source: go up to package root (from out/src/__tests__ or src/__tests__) |
44 | | - let current = __dirname; |
45 | | - while (!fs.existsSync(pathModule.join(current, 'package.json'))) { |
46 | | - const parent = pathModule.resolve(current, '..'); |
47 | | - if (parent === current) break; // reached filesystem root |
48 | | - current = parent; |
49 | | - } |
50 | | - const filePath = pathModule.join(current, 'src', 'resources', 'core', 'jsconfig-core.json'); |
51 | | - const content = JSON.parse(fs.readFileSync(filePath, 'utf8')); |
52 | | - // JSON imports in TypeScript are treated as default exports |
53 | | - // eslint-disable-next-line @typescript-eslint/no-unsafe-return |
54 | | - return { default: content, ...content }; |
55 | | -}); |
56 | | - |
57 | | -jest.mock('../resources/core/settings-core.json', () => { |
58 | | - // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment |
59 | | - const fs = require('node:fs'); |
60 | | - // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment |
61 | | - const pathModule = require('node:path'); |
62 | | - // Always read from source: go up to package root (from out/src/__tests__ or src/__tests__) |
63 | | - let current = __dirname; |
64 | | - while (!fs.existsSync(pathModule.join(current, 'package.json'))) { |
65 | | - const parent = pathModule.resolve(current, '..'); |
66 | | - if (parent === current) break; // reached filesystem root |
67 | | - current = parent; |
68 | | - } |
69 | | - const filePath = pathModule.join(current, 'src', 'resources', 'core', 'settings-core.json'); |
70 | | - const content = JSON.parse(fs.readFileSync(filePath, 'utf8')); |
71 | | - // JSON imports in TypeScript are treated as default exports |
72 | | - // eslint-disable-next-line @typescript-eslint/no-unsafe-return |
73 | | - return { default: content, ...content }; |
74 | | -}); |
75 | | - |
76 | | -jest.mock('../resources/sfdx/jsconfig-sfdx.json', () => { |
77 | | - // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment |
78 | | - const fs = require('node:fs'); |
79 | | - // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment |
80 | | - const pathModule = require('node:path'); |
81 | | - // Always read from source: go up to package root (from out/src/__tests__ or src/__tests__) |
82 | | - let current = __dirname; |
83 | | - while (!fs.existsSync(pathModule.join(current, 'package.json'))) { |
84 | | - const parent = pathModule.resolve(current, '..'); |
85 | | - if (parent === current) break; // reached filesystem root |
86 | | - current = parent; |
87 | | - } |
88 | | - const filePath = pathModule.join(current, 'src', 'resources', 'sfdx', 'jsconfig-sfdx.json'); |
89 | | - const content = JSON.parse(fs.readFileSync(filePath, 'utf8')); |
90 | | - // JSON imports in TypeScript are treated as default exports |
91 | | - // eslint-disable-next-line @typescript-eslint/no-unsafe-return |
92 | | - return { default: content, ...content }; |
93 | | -}); |
94 | 38 |
|
95 | 39 | beforeAll(() => { |
96 | 40 | // make sure test runner config doesn't overlap with test workspace |
@@ -201,29 +145,6 @@ describe('WorkspaceContext', () => { |
201 | 145 | } |
202 | 146 | }); |
203 | 147 |
|
204 | | - it('processTemplate() with EJS', async () => { |
205 | | - const templateString = ` |
206 | | -{ |
207 | | - "compilerOptions": { |
208 | | - "baseUrl": "<%= project_root %>", |
209 | | - "paths": { |
210 | | - "@/*": ["<%= project_root %>/src/*"] |
211 | | - } |
212 | | - } |
213 | | -}`; |
214 | | - |
215 | | - const variableMap = { |
216 | | - project_root: '/path/to/project' |
217 | | - }; |
218 | | - |
219 | | - // Use the standalone function |
220 | | - const result = processTemplate(templateString, variableMap); |
221 | | - |
222 | | - expect(result).toContain('"baseUrl": "/path/to/project"'); |
223 | | - expect(result).toContain('"@/*": ["/path/to/project/src/*"]'); |
224 | | - expect(result).not.toContain('${project_root}'); |
225 | | - }); |
226 | | - |
227 | 148 | it('configureSfdxProject()', async () => { |
228 | 149 | const context = new WorkspaceContext(SFDX_WORKSPACE_PATH, sfdxFileSystemProvider); |
229 | 150 | await context.initialize(); |
|
0 commit comments