import { AppError } from '../src/common/errors/app-error'; import { estimateLineCost, sumCosts } from '../src/costing/cost-math'; describe('cost estimate arithmetic', () => { it('uses exact decimal arithmetic with half-up rounding per line', () => { expect(estimateLineCost('0.125', '2.3000')).toBe('0.29'); expect(estimateLineCost('1.000', '0.0050')).toBe('0.01'); expect(sumCosts(['0.29', '0.01'])).toBe('0.30'); }); it('rejects amounts beyond the supported money range', () => { expect(() => estimateLineCost('999999999.000', '99999999.0000')).toThrow( AppError, ); }); });