@@ -0,0 +1,65 @@
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { expect, test } from 'vitest';
|
||||
import BudgetDistributionFields from '@/components/budget-distribution-fields';
|
||||
|
||||
test('explicit MZN input preserves decimal strings and identifies each article and centre accessibly', () => {
|
||||
const row = {
|
||||
allocation_key: 'qa-a',
|
||||
line_id: 12,
|
||||
centre_id: 4,
|
||||
subtotal: '999999999999.99',
|
||||
total: '999999999999.99',
|
||||
};
|
||||
const html = renderToStaticMarkup(
|
||||
<BudgetDistributionFields
|
||||
options={[
|
||||
{
|
||||
...row,
|
||||
line_label: 'Artigo sintético',
|
||||
centre_label: 'Produção sintética',
|
||||
},
|
||||
]}
|
||||
rows={[row]}
|
||||
onChange={() => {}}
|
||||
reason=""
|
||||
onReason={() => {}}
|
||||
/>,
|
||||
);
|
||||
expect(html).toContain('Artigo sintético');
|
||||
expect(html).toContain('Produção sintética');
|
||||
expect(html.match(/value="999999999999.99"/g)).toHaveLength(2);
|
||||
expect(html).toContain('Sem IVA (MZN)');
|
||||
expect(html).toContain('Total (MZN)');
|
||||
expect(html).toContain('minLength="10"');
|
||||
expect(html).toContain(
|
||||
'Nenhuma diferença será distribuída automaticamente',
|
||||
);
|
||||
});
|
||||
|
||||
test('unknown partial allocations stay blank until explicitly entered', () => {
|
||||
const row = {
|
||||
allocation_key: 'qa-b',
|
||||
line_id: 13,
|
||||
centre_id: 5,
|
||||
subtotal: '',
|
||||
total: '',
|
||||
};
|
||||
const html = renderToStaticMarkup(
|
||||
<BudgetDistributionFields
|
||||
options={[
|
||||
{
|
||||
...row,
|
||||
line_label: 'Outro artigo',
|
||||
centre_label: 'Outro centro',
|
||||
},
|
||||
]}
|
||||
rows={[row]}
|
||||
onChange={() => {}}
|
||||
reason=""
|
||||
onReason={() => {}}
|
||||
/>,
|
||||
);
|
||||
expect(html.match(/value=""/g)).toHaveLength(2);
|
||||
expect(html).not.toContain('value="0"');
|
||||
expect(html).toContain('inputMode="decimal"');
|
||||
});
|
||||
Reference in New Issue
Block a user