arm-web/src/widgets/DocumentReview/confirmBlockers.test.ts

35 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, expect, it } from 'vitest';
import type { StatementOut, ValueOut } from '../../types/api';
import statementV2Json from './__fixtures__/statement-v2.json';
import { unresolvedHint, unresolvedLines } from './confirmBlockers';
import { type GridRow, buildStatementGrid } from './statementGrid';
const { rows } = buildStatementGrid(statementV2Json as unknown as StatementOut);
const emptyCell = { amount: null, string_value: null } as ValueOut;
const row = (patch: Partial<GridRow>): GridRow => ({ ...rows[0], cells: {}, ...patch });
describe('unresolvedLines', () => {
it('фикстура: строки без кода со значениями', () => {
expect(unresolvedLines(rows).map((r) => r.lineId)).toEqual(['l-u7', 'l-m8']);
});
it('missing без значений не блокирует', () => {
expect(unresolvedLines([row({ lineStatus: 'missing', cells: { a: emptyCell } })])).toEqual([]);
});
it('unreadable только со string_value блокирует', () => {
const r = row({ lineStatus: 'unreadable', cells: { a: { ...emptyCell, string_value: '211(1 |' } } });
expect(unresolvedLines([r])).toEqual([r]);
});
it('detail с суммой не блокирует', () => {
expect(unresolvedLines([row({ lineStatus: 'detail', cells: { a: { ...emptyCell, amount: '1.00' } } })])).toEqual([]);
});
it('форма 1.x: все ok — пусто', () => {
expect(unresolvedLines(rows.filter((r) => r.lineStatus === 'ok'))).toEqual([]);
});
});
describe('unresolvedHint', () => {
it('текст', () => {
expect(unresolvedHint(2)).toBe('Разберите строки без кода: 2');
});
});