arm-core/web/src/widgets/NewConsoleModal/preselect.test.ts
2026-10-08 18:09:07 +03:00

29 lines
984 B
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 { membersFirst, preselectMembers } from './preselect';
const entities = [
{ id: 'a', name: 'А', inn: '1' },
{ id: 'b', name: 'Б', inn: '2' },
];
describe('preselectMembers', () => {
it('отмечает только тех членов ГСК, что есть среди ЮЛ ГК', () => {
expect(preselectMembers(['b', 'x'], entities)).toEqual(['b']);
});
it('пустая ГСК — ничего', () => {
expect(preselectMembers([], entities)).toEqual([]);
});
});
describe('membersFirst', () => {
it('члены ГСК — наверх, порядок внутри групп сохраняется', () => {
const list = [
{ id: 'a', name: 'А', inn: '1' },
{ id: 'b', name: 'Б', inn: '2' },
{ id: 'c', name: 'В', inn: '3' },
];
expect(membersFirst(list, ['c']).map((e) => e.id)).toEqual(['c', 'a', 'b']);
expect(membersFirst(list, []).map((e) => e.id)).toEqual(['a', 'b', 'c']);
});
});