/** * Session 64 — CLV badge rendering model. Absence must be a NON-ELEMENT. */ const { clvBadge } = require('../../web/src/lib/clvBadge'); const read = (o = {}) => ({ dclv_state: 'positive', locked_odds: '-110', closing_odds: '-145', ...o }); describe('ABSENCE IS HONEST — renders NOTHING', () => { test('unknown → null (no element, not "pending")', () => { expect(clvBadge(read({ dclv_state: 'unknown' }))).toBeNull(); }); test('flat → null (a held line is not news)', () => { expect(clvBadge(read({ dclv_state: 'flat' }))).toBeNull(); }); test('missing state → null', () => { expect(clvBadge(read({ dclv_state: null }))).toBeNull(); expect(clvBadge({})).toBeNull(); expect(clvBadge(null)).toBeNull(); }); test('a Free response (CLV stripped server-side) renders nothing', () => { const free = { player_name: 'X', grade: 'B', locked_odds: '-110' }; // no dclv_* expect(clvBadge(free)).toBeNull(); }); test('no receipt numbers → NO badge (a label without evidence is an assertion)', () => { expect(clvBadge(read({ closing_odds: null }))).toBeNull(); expect(clvBadge(read({ locked_odds: null }))).toBeNull(); }); }); describe('THE RECEIPT — numbers, not just a label', () => { test('positive carries tone, label and the concrete prices', () => { const b = clvBadge(read()); expect(b.tone).toBe('confirm'); expect(b.label).toBe('MOVED TOWARD US'); expect(b.receipt).toBe('graded -110 · closed -145'); }); test('negative is CAUTION and also carries the receipt', () => { const b = clvBadge(read({ dclv_state: 'negative', closing_odds: '+120' })); expect(b.tone).toBe('caution'); expect(b.receipt).toBe('graded -110 · closed +120'); }); test('positive prices render with an explicit +', () => { expect(clvBadge(read({ locked_odds: 105, closing_odds: 130 })).receipt) .toBe('graded +105 · closed +130'); }); }); describe('BOARD SHAPES — all-null and mixed both render clean', () => { const board = [ read({ dclv_state: 'positive' }), read({ dclv_state: 'unknown' }), read({ dclv_state: 'flat' }), { player_name: 'free-view', grade: 'B' }, ]; test('a MIXED board badges only the real signals', () => { const badges = board.map(clvBadge); expect(badges.filter(Boolean)).toHaveLength(1); expect(badges[1]).toBeNull(); expect(badges[2]).toBeNull(); }); test('an ALL-NULL board (today) produces zero badges and no errors', () => { const allNull = [read({ dclv_state: 'unknown' }), read({ dclv_state: null }), {}]; expect(allNull.map(clvBadge).filter(Boolean)).toHaveLength(0); }); }); describe('NO AGGREGATE anywhere', () => { test('the module exposes no count/rollup helper', () => { const mod = require('../../web/src/lib/clvBadge'); expect(Object.keys(mod).sort()).toEqual(['clvBadge', 'fmtPrice']); }); test('a badge payload carries no totals', () => { const b = clvBadge(read()); expect(Object.keys(b).sort()).toEqual(['label', 'receipt', 'tone']); }); });