-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_visual.js
More file actions
29 lines (24 loc) · 837 Bytes
/
Copy pathtest_visual.js
File metadata and controls
29 lines (24 loc) · 837 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
25
26
27
28
29
#!/usr/bin/env node
// Backward-compatible visual-module check without external packages.
// The old version required jsdom but did not use it, which made the test fail
// on a clean machine. Keep this file as a lightweight wrapper.
const fs = require('fs');
const vm = require('vm');
const file = 'js/features/visual.js';
const code = fs.readFileSync(file, 'utf8');
new vm.Script(code, { filename: file });
const expectedFunctions = [
'switchToCode',
'switchToVisual',
'switchToSplit',
'execCmd',
'insertImagePrompt',
'insertLinkPrompt',
'insertTablePrompt'
];
for (const name of expectedFunctions) {
if (!new RegExp(`function\\s+${name}\\s*\\(`).test(code) && !new RegExp(`${name}\\s*[:=]`).test(code)) {
throw new Error(`Missing visual feature entry: ${name}`);
}
}
console.log('visual feature syntax ok');