20 lines
935 B
JavaScript
20 lines
935 B
JavaScript
'use strict';
|
|
|
|
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
test('every literal web shim command has a registered server implementation', () => {
|
|
const root = path.resolve(__dirname, '../..');
|
|
const shim = fs.readFileSync(path.join(root, 'renderer', 'pork-web-shim.js'), 'utf8');
|
|
const invoked = new Set([...shim.matchAll(/\binvoke\(\s*['"]([^'"]+)['"]/g)].map(match => match[1]));
|
|
const registrySources = [
|
|
path.join(root, 'src', 'server', 'create-registry.js'),
|
|
path.join(root, 'src', 'server', 'register-functional-modules.js'),
|
|
].map(file => fs.readFileSync(file, 'utf8')).join('\n');
|
|
const registered = new Set([...registrySources.matchAll(/\bname:\s*['"]([^'"]+)['"]/g)].map(match => match[1]));
|
|
const missing = [...invoked].filter(command => !registered.has(command)).sort();
|
|
assert.deepEqual(missing, []);
|
|
});
|