import { describe, expect, it } from 'vitest'; import { chessMatrixRequest, isWholePerimeter } from './chessMatrixRequest'; describe('chessMatrixRequest', () => { it('пустые фильтры — пустые списки: все балансовые счета и весь периметр', () => { expect(chessMatrixRequest([], [], [])).toEqual({ debit_account_ids: [], credit_account_ids: [], legal_entity_ids: [] }); }); it('выбранные счета и компании уходят в запрос как есть', () => { expect(chessMatrixRequest(['d1'], ['c1', 'c2'], ['le1'])).toEqual({ debit_account_ids: ['d1'], credit_account_ids: ['c1', 'c2'], legal_entity_ids: ['le1'], }); }); it('списки копируются: правка фильтра после отправки не меняет тело', () => { const companies = ['le1']; const body = chessMatrixRequest([], [], companies); companies.push('le2'); expect(body.legal_entity_ids).toEqual(['le1']); }); }); describe('isWholePerimeter', () => { it('без выбора компаний ответ содержит весь периметр — из него строятся варианты фильтра', () => { expect(isWholePerimeter(chessMatrixRequest(['d1'], ['c1'], []))).toBe(true); }); it('с выбором компаний ответ сужен — варианты фильтра не трогаем', () => { expect(isWholePerimeter(chessMatrixRequest([], [], ['le1']))).toBe(false); }); });