// « Combien il faut de oui pour passer, combien de non pour bloquer » (Yvv, 2026-11-02), // told from what the server says (ADR 0013): yesNeeded, noNeeded, the quorum. import { describe, expect, it } from 'vitest'; import { needOf } from '../../src/lib/labels'; import type { Evaluation, Proposal } from '../../src/lib/types'; function version(tally: { for: number; against: number }, e: Partial | null): Proposal { const evaluation: Evaluation | null = e ? { cast: tally.for + tally.against, required: 0, reached: false, missing: 0, requiredRatio: 0, wellRated: false, ...e } : null; return { tally, evaluation } as unknown as Proposal; } describe('the yes to pass, the no to block', () => { it('before any vote: the yes asked of the quorum', () => { const need = needOf(version({ for: 0, against: 0 }, { quorum: 12, yesNeeded: 9, noNeeded: 0 })); expect(need?.long).toBe('9 oui sur 12 votants pour passer'); expect(need?.short).toBe('9 oui sur 12'); expect(need?.title).toBe('Quorum : 12 votants. En dessous, les votants qui manquent comptent comme « non ».'); }); it('one voter of quorum: singular', () => { expect(needOf(version({ for: 0, against: 0 }, { quorum: 1, yesNeeded: 1, noNeeded: 0 }))?.long).toBe('1 oui sur 1 votant pour passer'); }); it('9 for and 4 against at level 2, quorum 12: 11 yes pass, 4 no block', () => { const need = needOf(version({ for: 9, against: 4 }, { quorum: 12, yesNeeded: 11, noNeeded: 4 })); expect(need?.long).toBe('11 oui pour passer · 4 non pour bloquer'); expect(need?.short).toBe('passe à 11 oui · bloquée à 4 non'); }); it('below the quorum, the voters missing hold it alone: no « non » to count', () => { const need = needOf(version({ for: 3, against: 0 }, { quorum: 12, yesNeeded: 9, noNeeded: 0 })); expect(need?.long).toBe('9 oui pour passer · le quorum la bloque'); expect(need?.short).toBe('passe à 9 oui'); }); it('nothing said without the numbers of the server', () => { expect(needOf(version({ for: 0, against: 0 }, null))).toBeNull(); expect(needOf(version({ for: 0, against: 0 }, { quorum: 12 }))).toBeNull(); }); });