Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BJKMLHdxMwSUeYcdkwqX4W
35 lines
1.6 KiB
TypeScript
35 lines
1.6 KiB
TypeScript
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');
|
||
});
|
||
});
|