@@ -0,0 +1,36 @@
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { expect, test } from 'vitest';
|
||||
import {
|
||||
ReceiptConversionFields,
|
||||
convertedQuantity,
|
||||
} from '@/components/receipt-conversion';
|
||||
|
||||
test('converted quantity display preserves exact millesimals beyond floating point precision', () => {
|
||||
expect(convertedQuantity('24000')).toBe('24,000');
|
||||
expect(convertedQuantity('1')).toBe('0,001');
|
||||
expect(convertedQuantity('999999999999999999')).toBe('999999999999999,999');
|
||||
expect(convertedQuantity('')).toBe('Não disponível');
|
||||
});
|
||||
|
||||
test('receipt conversion identifies both units and requires an explicit rational factor and documentary source', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<ReceiptConversionFields
|
||||
documentUnit="cx"
|
||||
stockUnit="un"
|
||||
value={{
|
||||
numerator: '12',
|
||||
denominator: '1',
|
||||
source: 'Embalagem sintética',
|
||||
version: 'QA-1',
|
||||
}}
|
||||
onChange={() => {}}
|
||||
/>,
|
||||
);
|
||||
expect(html).toContain('Conversão de cx para un');
|
||||
expect(html).toContain('A compra conserva cx');
|
||||
expect(html).toContain('O stock e os lotes usam un');
|
||||
expect(html).toContain('Não há arredondamento automático');
|
||||
expect(html).toContain('Fonte do factor');
|
||||
expect(html).toContain('Versão da fonte');
|
||||
expect(html.match(/required=""/g)).toHaveLength(4);
|
||||
});
|
||||
Reference in New Issue
Block a user