637e51d7f9
Tests / frontend-test (push) Successful in 1m24s
Co-authored-by: gorbenko.pavel <gorbenko.pavel@tansu.kz> Reviewed-on: http://git.tnsu.kz/timur.gorodetskiy/request-portal/pulls/23
29 lines
1.7 KiB
TypeScript
29 lines
1.7 KiB
TypeScript
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: '' });
|
||
});
|
||
});
|