commit compras1 2811
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-28 07:11:35 +02:00
parent d58b75c87a
commit eb32c74c56
202 changed files with 17463 additions and 1526 deletions
@@ -0,0 +1,35 @@
import { expect, test } from 'vitest';
import vectors from '../Fixtures/requisition-estimates.json';
import { requisitionEstimate } from '@/lib/requisition-estimate';
test.each(vectors)(
'preserves exact native line rounding: $minor',
({ lines, minor }) => {
expect(requisitionEstimate(lines)).toBe(minor);
},
);
test.each(['', '-1', '1e2', '0', '1.0001', '1000001', 'x'])(
'keeps invalid or incomplete quantity indeterminate: %s',
(quantity) => {
expect(
requisitionEstimate([{ quantity, unit_price: '1', tax_rate: '0' }]),
).toBeNull();
},
);
test('requires complete valid lines while accepting leading zeros and calculated zero', () => {
expect(requisitionEstimate([])).toBeNull();
for (const field of ['unit_price', 'tax_rate']) {
expect(
requisitionEstimate([
{ quantity: '1', unit_price: '1', tax_rate: '0', [field]: '' },
]),
).toBeNull();
}
expect(
requisitionEstimate([
{ quantity: '000.001', unit_price: '00.01', tax_rate: '00.00' },
]),
).toBe('0');
});