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('Bedside respiratory and ventilation references render without requiring weight', () => {
  const respiratory = read('public/js/bedside/respiratory.js');
  const ventilation = read('public/js/bedside/ventilation.js');

  assert.doesNotMatch(respiratory, /Enter weight \(kg\)/);
  assert.match(respiratory, /function ipratropiumDose\(wt\)/);
  assert.match(respiratory, /return mgPerKg \+ ' ' \+ uTrim \+ '\/kg'/);
  assert.match(ventilation, /wt \? '1-2 L\/kg\/min = '/);
  assert.match(ventilation, /: '1-2 L\/kg\/min'/);
  assert.match(ventilation, /wt \? S\.d\(wt, 6\) \+ '-' \+ S\.d\(wt, 8\) \+ ' mL' : '6-8 mL\/kg'/);
});
