import { describe, it, expect } from 'vitest'; import { countingAccuracy, sackAccuracy, weightAccuracy, combinedMortality, } from '../reportAccuracy.ts'; describe('countingAccuracy', () => { it('uses smaller/larger × 100 for IoT vs after-count', () => { expect(countingAccuracy(95, 100)).toBe(95); }); it('returns no accuracy when after-count is 0', () => { expect(countingAccuracy(95, 0)).toBeNull(); }); it('returns no accuracy when IoT count is missing', () => { expect(countingAccuracy(null, 100)).toBeNull(); expect(countingAccuracy(undefined, 100)).toBeNull(); }); }); describe('sackAccuracy', () => { it('is 100% when both sides are 0', () => { expect(sackAccuracy(0, 0)).toBe(100); }); it('is N/A when only IoT is set', () => { expect(sackAccuracy(null, 10)).toBeNull(); expect(sackAccuracy(0, 10)).toBeNull(); }); it('is 100% when both sides are 10', () => { expect(sackAccuracy(10, 10)).toBe(100); }); }); describe('weightAccuracy', () => { it('uses smaller/larger × 100 for average IoT vs average manual', () => { expect(weightAccuracy(1000, 900)).toBe(90); }); }); describe('combinedMortality', () => { it('sums mati + afkir and ignores panen', () => { expect(combinedMortality(3, 2, 10)).toBe(5); }); });