Co-authored-by: gorbenko.pavel <gorbenko.pavel@tansu.kz> Reviewed-on: http://git.tnsu.kz/timur.gorodetskiy/request-portal/pulls/23
This commit was merged in pull request #23.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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: '' });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user