// Casos sinteticos de especificacao; nao demonstram RF-EDU implementados. import test from 'node:test'; import assert from 'node:assert/strict'; import { observedGap } from './gap-calculator.mjs'; const context = { occupation: 'SYNTHETIC-OCC', qualification: 'SYNTHETIC-Q', territory: 'SYNTHETIC-T', period: 'SYNTHETIC-P', unit: 'people', }; const input = { demand: 10, available: 4, context, supplyContext: { ...context }, sourceValid: true, }; await test('comparable synthetic people produce an unvalidated deficit', () => { assert.deepEqual(observedGap(input), { state: 'observed_unvalidated', people: 6, }); }); await test('unknown supply is not zero; zero supply is explicitly distinguishable', () => { assert.deepEqual(observedGap({ ...input, available: null }), { state: 'insufficient_data', people: null, }); assert.equal(observedGap({ ...input, available: 0 }).people, 10); }); await test('training seats cannot count as available workers', () => { assert.equal( observedGap({ ...input, supplyContext: { ...context, unit: 'seats' } }) .state, 'incomparable', ); }); await test('incompatible occupation, qualification, territory or period is excluded', () => { for (const key of ['occupation', 'qualification', 'territory', 'period']) { assert.equal( observedGap({ ...input, supplyContext: { ...context, [key]: 'different' }, }).state, 'incomparable', ); } }); await test('expired sources never produce a current deficit', () => { assert.deepEqual(observedGap({ ...input, sourceValid: false }), { state: 'expired', people: null, }); }); await test('surplus never produces a negative deficit or an institutional decision', () => { assert.deepEqual(observedGap({ ...input, available: 20 }), { state: 'observed_unvalidated', people: 0, }); }); await test('invalid counts, missing context and implicit validity are rejected', () => { for (const demand of [ -1, 1.5, undefined, '10', Number.MAX_SAFE_INTEGER + 1, ]) { assert.throws(() => observedGap({ ...input, demand }), TypeError); } assert.throws(() => observedGap({ ...input, context: {} }), TypeError); assert.throws( () => observedGap({ ...input, sourceValid: undefined }), TypeError, ); });