/** * Low wall mouldings must not run through exit doors on the end walls. * node --test server/__tests__/doorway-clearance.test.js */ const { describe, it } = require('node:test'); const assert = require('node:assert/strict'); const fs = require('node:fs'); const path = require('node:path'); const ROOT = path.join(__dirname, '..', '..'); const PRIMITIVES = fs.readFileSync(path.join(ROOT, 'client/src/components/hall-details/primitives.tsx'), 'utf8'); const GEOMETRY = fs.readFileSync(path.join(ROOT, 'client/src/components/hall-details/geometry.ts'), 'utf8'); const COURTLY = fs.readFileSync(path.join(ROOT, 'client/src/components/hall-details/courtly.tsx'), 'utf8'); function flemishBlock() { const start = COURTLY.indexOf('export function FlemishDetails'); assert.ok(start >= 0); const next = COURTLY.indexOf('export function ', start + 1); return COURTLY.slice(start, next > start ? next : undefined); } describe('Doorway clearance for wall mouldings', () => { it('exports a shared door half-clearance used by WallBand', () => { assert.match(GEOMETRY, /DOOR_CLEAR_HALF\s*=\s*1\.45/); assert.match(PRIMITIVES, /DOOR_CLEAR_HALF/); }); it('WallBand splits back/front bands that sit in the door height', () => { assert.match(PRIMITIVES, /crossesDoor/); assert.match(PRIMITIVES, /DOOR_CLEAR_HALF/); assert.match(PRIMITIVES, /leftX|rightX/); }); it('Flemish linenfold ribs skip the back-wall doorway', () => { const block = flemishBlock(); assert.match(block, /DOOR_CLEAR_HALF|Math\.abs\(x\)\s*>/); }); });