/** * Ledger takeable tagging (specs/takeable-tagging.md). * * The load-bearing property: this standard is a FLOOR with an UNCAPPED plus side, * and it is DELIBERATELY NOT valueEngine's -160..+200 promotion band. A test that * lets the two converge would erase the distinction the ledger depends on. */ const { LEDGER_TAKEABLE_FLOOR, isLedgerTakeable } = require('../../src/config/takeableStandard'); const { isTakeable: isPromotable } = require('../../src/config/valueEngine'); describe('ledger takeable standard — floor on minus, UNCAPPED plus', () => { test('the floor is inclusive and a worse price is not takeable', () => { expect(isLedgerTakeable(LEDGER_TAKEABLE_FLOOR)).toBe(true); expect(isLedgerTakeable(LEDGER_TAKEABLE_FLOOR - 1)).toBe(false); expect(isLedgerTakeable(-110)).toBe(true); expect(isLedgerTakeable(-300)).toBe(false); }); test('the PLUS side is UNCAPPED — this is the whole ratified shape', () => { for (const p of [100, 200, 201, 400, 600, 5000]) { expect(isLedgerTakeable(p)).toBe(true); } }); test('an ABSENT price is NULL, never false (Number(null) === 0 guard)', () => { // Without the strict guard, Number(null) === 0 would be >= -160 and a MISSING // price would be tagged takeable — fabricated data in the record. expect(isLedgerTakeable(null)).toBeNull(); expect(isLedgerTakeable(undefined)).toBeNull(); expect(isLedgerTakeable('')).toBeNull(); expect(isLedgerTakeable('not-a-price')).toBeNull(); }); test('accepts the string prices the ledger actually stores', () => { expect(isLedgerTakeable('-110')).toBe(true); expect(isLedgerTakeable('+150')).toBe(true); expect(isLedgerTakeable('-275')).toBe(false); }); }); describe('it must NOT collapse into the promotion band', () => { test('a long plus price is TAKEABLE but NOT promotable — both true at once', () => { const longshot = 400; expect(isLedgerTakeable(longshot)).toBe(true); // a bettor could take it expect(isPromotable(longshot)).toBe(false); // we would not hero it }); test('the two disagree on the plus side and AGREE on the minus floor', () => { expect(isLedgerTakeable(-160)).toBe(true); expect(isPromotable(-160)).toBe(true); expect(isLedgerTakeable(-161)).toBe(false); expect(isPromotable(-161)).toBe(false); // divergence is confined to the plus side expect(isLedgerTakeable(250)).toBe(true); expect(isPromotable(250)).toBe(false); }); }); describe('the pipeline row carries the tag and the floor it was judged under', () => { const svc = require('../../src/services/ledgerService'); test('ledgerService requires the ledger standard, not the promotion band', () => { const src = require('fs').readFileSync( require('path').join(__dirname, '../../src/services/ledgerService.js'), 'utf8', ); expect(src).toMatch(/require\('\.\.\/config\/takeableStandard'\)/); expect(src).toMatch(/takeable: takeableFor\(/); expect(src).toMatch(/takeable_floor: LEDGER_TAKEABLE_FLOOR/); }); test('the service module loads and exposes its record builder', () => { expect(typeof svc.recordPipelineGrades).toBe('function'); }); });