Files
request-portal/src/webparts/requestPortal/shared/dictionary/employeeOrganizations.test.ts
T
gorbenko.pavel 637e51d7f9
Tests / frontend-test (push) Successful in 1m24s
Feature/vacation edo signing (#23)
Co-authored-by: gorbenko.pavel <gorbenko.pavel@tansu.kz>
Reviewed-on: http://git.tnsu.kz/timur.gorodetskiy/request-portal/pulls/23
2026-10-05 08:53:18 +00:00

29 lines
1.7 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 { IEmployeeOrganization } from './models/IEmployeeOrganization';
import { formatEmployeeOrganizationsWithDepartment, parseOrganizationLine } from './organizationLines';
const rec = (p: Partial<IEmployeeOrganization>): IEmployeeOrganization => ({
id: '', fio: '', email: '', iin: '', company: 'ТОО А', companyId: '', section: '', departmentId: '', position: '', mobile: '', ...p
});
describe('организации с подразделением', () => {
it('на каждую организацию своё подразделение', () => {
const text = formatEmployeeOrganizationsWithDepartment([
rec({ company: 'ТОО А', position: 'Директор', section: 'Дирекция' }),
rec({ company: 'ТОО Б', position: 'Казначей', section: 'Финансы' })
]);
expect(text.split('\n').map(parseOrganizationLine)).toEqual([
{ company: 'ТОО А', position: 'Директор', department: 'Дирекция' },
{ company: 'ТОО Б', position: 'Казначей', department: 'Финансы' }
]);
});
it('без подразделения формат прежний «Компания — должность»', () => {
expect(formatEmployeeOrganizationsWithDepartment([rec({ position: 'Директор' })])).toBe('ТОО А — Директор');
});
it('старые строки разбираются с пустым подразделением', () => {
expect(parseOrganizationLine('ТОО А — Директор')).toEqual({ company: 'ТОО А', position: 'Директор', department: '' });
expect(parseOrganizationLine('ТОО А')).toEqual({ company: 'ТОО А', position: '', department: '' });
});
});