Несколько условий шага, объединяемых через И/ИЛИ (#16)
<html> <body> <!--StartFragment--> GetEmployeeByEmailAsync возвращает массив; новый HeadType.CompanyDirectors -- <!--EndFragment--> </body> </html>[GetEmployeeByEmailAsync возвращает массив; новый HeadType.CompanyDirectors](http://git.tnsu.kz/gorbenko.pavel/tnsu-approval-route/commit/572749b4d7cc11bc8e1ef4184a93f18a14b710ab) --------- Co-authored-by: gorbenko.pavel <gorbenko.pavel@tansu.kz> Reviewed-on: http://git.tnsu.kz/gorbenko.pavel/tnsu-approval-route/pulls/16
This commit was merged in pull request #16.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ComparisonOperator, Employee, HeadType, ProjectRole, RouteStepStatus, TemplateRouteStep } from '../models';
|
||||
import { ComparisonOperator, ConditionsLogic, Employee, HeadType, ProjectRole, RouteStepStatus, TemplateRouteStep } from '../models';
|
||||
import { describeStepCondition, describeStepExecutor, detectExecutorKind } from './stepExecutor';
|
||||
|
||||
function step(overrides: Partial<TemplateRouteStep>): TemplateRouteStep {
|
||||
@@ -12,9 +12,8 @@ function step(overrides: Partial<TemplateRouteStep>): TemplateRouteStep {
|
||||
status: RouteStepStatus.Approval,
|
||||
routeId: 1,
|
||||
allowReassignToOtherApprovers: false,
|
||||
fieldName: null,
|
||||
operation: null,
|
||||
value: null,
|
||||
conditions: [],
|
||||
conditionsLogic: ConditionsLogic.And,
|
||||
slaHours: null,
|
||||
askOverdueReason: null,
|
||||
...overrides
|
||||
@@ -95,16 +94,40 @@ describe('describeStepExecutor', () => {
|
||||
});
|
||||
|
||||
describe('describeStepCondition', () => {
|
||||
it('undefined, если условие не задано целиком', () => {
|
||||
it('undefined, если условий нет', () => {
|
||||
expect(describeStepCondition(step({}))).toBeUndefined();
|
||||
});
|
||||
|
||||
it('undefined, если operation === None', () => {
|
||||
expect(describeStepCondition(step({ fieldName: 'Amount', operation: ComparisonOperator.None, value: '100' }))).toBeUndefined();
|
||||
});
|
||||
|
||||
it('собирает "поле оператор значение", если условие задано полностью', () => {
|
||||
const result = describeStepCondition(step({ fieldName: 'Amount', operation: ComparisonOperator.GreaterThan, value: '100' }));
|
||||
it('собирает "поле оператор значение", если условие одно', () => {
|
||||
const result = describeStepCondition(
|
||||
step({ conditions: [{ fieldName: 'Amount', operation: ComparisonOperator.GreaterThan, value: '100' }] })
|
||||
);
|
||||
expect(result).toBe('Amount > 100');
|
||||
});
|
||||
|
||||
it('несколько условий склеиваются через "И"', () => {
|
||||
const result = describeStepCondition(
|
||||
step({
|
||||
conditions: [
|
||||
{ fieldName: 'Amount', operation: ComparisonOperator.GreaterThan, value: '1000' },
|
||||
{ fieldName: 'Priority', operation: ComparisonOperator.Equal, value: 'Urgent' }
|
||||
],
|
||||
conditionsLogic: ConditionsLogic.And
|
||||
})
|
||||
);
|
||||
expect(result).toBe('Amount > 1000 И Priority = Urgent');
|
||||
});
|
||||
|
||||
it('несколько условий склеиваются через "ИЛИ"', () => {
|
||||
const result = describeStepCondition(
|
||||
step({
|
||||
conditions: [
|
||||
{ fieldName: 'Amount', operation: ComparisonOperator.GreaterThan, value: '1000' },
|
||||
{ fieldName: 'Priority', operation: ComparisonOperator.Equal, value: 'Urgent' }
|
||||
],
|
||||
conditionsLogic: ConditionsLogic.Or
|
||||
})
|
||||
);
|
||||
expect(result).toBe('Amount > 1000 ИЛИ Priority = Urgent');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user