|
|
|
@ -71,91 +71,55 @@ describe('TransactionController Unit Tests', () => { |
|
|
|
|
|
|
|
|
|
it('calling applyRules method minimum result of applied rules should be got', async () => { |
|
|
|
|
{ |
|
|
|
|
const result = await transactionController.applyRules( |
|
|
|
|
[ |
|
|
|
|
transactionController.discountRule, |
|
|
|
|
transactionController.turnoverRule, |
|
|
|
|
], |
|
|
|
|
{ |
|
|
|
|
base_amount: 1000, |
|
|
|
|
client_id: 1, |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
const result = await transactionController.applyRules({ |
|
|
|
|
base_amount: 1000, |
|
|
|
|
client_id: 1, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
expect(result).to.eql(5); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
const result = await transactionController.applyRules( |
|
|
|
|
[ |
|
|
|
|
transactionController.discountRule, |
|
|
|
|
transactionController.turnoverRule, |
|
|
|
|
], |
|
|
|
|
{ |
|
|
|
|
base_amount: 1, |
|
|
|
|
client_id: 1, |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
const result = await transactionController.applyRules({ |
|
|
|
|
base_amount: 1, |
|
|
|
|
client_id: 1, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
expect(result).to.eql(0.05); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
const result = await transactionController.applyRules( |
|
|
|
|
[ |
|
|
|
|
transactionController.discountRule, |
|
|
|
|
transactionController.turnoverRule, |
|
|
|
|
], |
|
|
|
|
{ |
|
|
|
|
base_amount: 1000, |
|
|
|
|
client_id: 42, |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
const result = await transactionController.applyRules({ |
|
|
|
|
base_amount: 1000, |
|
|
|
|
client_id: 42, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
expect(result).to.eql(0.03); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
const result = await transactionController.applyRules( |
|
|
|
|
[ |
|
|
|
|
transactionController.discountRule, |
|
|
|
|
transactionController.turnoverRule, |
|
|
|
|
], |
|
|
|
|
{ |
|
|
|
|
base_amount: 1, |
|
|
|
|
client_id: 42, |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
const result = await transactionController.applyRules({ |
|
|
|
|
base_amount: 1, |
|
|
|
|
client_id: 42, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
expect(result).to.eql(0.03); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
const result = await transactionController.applyRules( |
|
|
|
|
[ |
|
|
|
|
transactionController.discountRule, |
|
|
|
|
transactionController.turnoverRule, |
|
|
|
|
], |
|
|
|
|
{ |
|
|
|
|
base_amount: 1000, |
|
|
|
|
client_id: 99, |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
const result = await transactionController.applyRules({ |
|
|
|
|
base_amount: 1000, |
|
|
|
|
client_id: 99, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
expect(result).to.eql(0.03); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
const result = await transactionController.applyRules( |
|
|
|
|
[ |
|
|
|
|
transactionController.discountRule, |
|
|
|
|
transactionController.turnoverRule, |
|
|
|
|
], |
|
|
|
|
{ |
|
|
|
|
base_amount: 1, |
|
|
|
|
client_id: 99, |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
const result = await transactionController.applyRules({ |
|
|
|
|
base_amount: 1, |
|
|
|
|
client_id: 99, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
expect(result).to.eql(0.03); |
|
|
|
|
} |
|
|
|
|