forked from yvv/decision
La médiane de participation ne compte plus les propositions retirées (invisibles, votes non repris). Quand l'échelle ramène la participation dans ses bornes, les réglages disent la médiane mesurée (ou deux fois C) et, à part, la valeur sur laquelle les seuils se calculent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
// What the formula settings say about the usual participation (relecture of a576b68):
|
|
// the measured median, or twice C, even when the scale brings it back within its bounds.
|
|
import { describe, expect, it } from 'vitest';
|
|
import { usualShown } from '../../src/lib/participation';
|
|
import type { ParticipationInfo } from '../../src/lib/types';
|
|
|
|
const base: ParticipationInfo = {
|
|
ratio: 0.3,
|
|
source: 'median',
|
|
sample: 5,
|
|
median: 3,
|
|
bounded: false,
|
|
voters: 3,
|
|
minSample: 5,
|
|
windowDays: 365,
|
|
everyHours: 24,
|
|
bounds: [0.01, 0.5],
|
|
measuredAt: null,
|
|
};
|
|
|
|
describe('usual participation as shown', () => {
|
|
it('is the scale itself when nothing was bounded', () => {
|
|
expect(usualShown(base, 10, 1)).toEqual({ voters: 3, ratio: 0.3 });
|
|
});
|
|
it('is the real median when the scale raised it to its floor', () => {
|
|
const p = { ...base, median: 1, ratio: 0.01, voters: 57, bounded: true };
|
|
expect(usualShown(p, 5745, 50)).toEqual({ voters: 1, ratio: 1 / 5745 });
|
|
});
|
|
it('is twice C for the reference, even when the scale lowered it to its ceiling', () => {
|
|
const p = { ...base, source: 'reference' as const, median: null, sample: 0, ratio: 0.5, voters: 1, bounded: true };
|
|
expect(usualShown(p, 2, 1)).toEqual({ voters: 2, ratio: 1 });
|
|
});
|
|
it('rounds a median between two numbers of voters', () => {
|
|
const p = { ...base, median: 2.5, ratio: 0.01, voters: 57, bounded: true };
|
|
expect(usualShown(p, 5745, 50).voters).toBe(3);
|
|
});
|
|
});
|