move pe guide data to json
This commit is contained in:
parent
f3e2714e6f
commit
60290a044a
3 changed files with 4246 additions and 1316 deletions
4177
public/data/pe-guide.json
Normal file
4177
public/data/pe-guide.json
Normal file
File diff suppressed because it is too large
Load diff
1357
public/js/peGuide.js
1357
public/js/peGuide.js
File diff suppressed because it is too large
Load diff
28
test/pe-guide-data.test.js
Normal file
28
test/pe-guide-data.test.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
const { test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const root = path.join(__dirname, '..');
|
||||
|
||||
function read(relativePath) {
|
||||
return fs.readFileSync(path.join(root, relativePath), 'utf8');
|
||||
}
|
||||
|
||||
test('PE Guide static content is loaded from JSON data', () => {
|
||||
const source = read('public/js/peGuide.js');
|
||||
const data = JSON.parse(read('public/data/pe-guide.json'));
|
||||
|
||||
assert.match(source, /PE_GUIDE_DATA_URL = '\/data\/pe-guide\.json'/);
|
||||
assert.match(source, /async function init\(\)/);
|
||||
assert.match(source, /await loadPeGuideData\(\)/);
|
||||
assert.doesNotMatch(source, /newborn:\s*\{/);
|
||||
|
||||
assert.deepEqual(Object.keys(data.peData), ['newborn', 'infant', 'toddler', 'preschool', 'school', 'adolescent']);
|
||||
assert.ok(data.peData.newborn.msk.components.length > 0);
|
||||
assert.ok(data.peData.adolescent.cv.components.length > 0);
|
||||
assert.ok(data.scales.mrc.rows.length > 0);
|
||||
assert.ok(data.systemScales.cv.includes('murmurGrade'));
|
||||
assert.ok(data.respiratorySounds.length >= 7);
|
||||
assert.ok(data.cardiacSounds.length >= 6);
|
||||
});
|
||||
Loading…
Reference in a new issue