Solution#310
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great work on this task! I am approving your solution as it successfully meets all the requirements. The test suite is well-structured and logically covers all the individual rules from the description.
To make your tests even more robust, consider adding a test for an edge case where price rounding interacts with the customer's ability to pay. For example, what happens if a customer has 99.99 and the calculated fuel cost is 99.999? The cost rounds up to 100.00, which the customer cannot afford, so the transaction should not proceed. Testing this interaction would be a great addition to an already solid test suite.
Keep up the excellent work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| it('should round fuel price to nearest hundredth', () => { | ||
| const customer = { | ||
| money: 100, | ||
| vehicle: { | ||
| maxTankCapacity: 40, | ||
| fuelRemains: 10, | ||
| }, | ||
| }; | ||
|
|
||
| fillTank(customer, 33.333, 3); | ||
|
|
||
| expect(customer.vehicle.fuelRemains).toBe(13); | ||
| expect(customer.money).toBe(0); |
There was a problem hiding this comment.
This test correctly checks the price rounding requirement. To make your test suite more robust, consider adding another test case for an edge case: what happens if rounding the price upwards makes the purchase unaffordable for the customer?
For example, if a customer has 99.99 in their account, and the calculated cost is 99.999, it would round up to 100. According to the 'ALWAYS fill in only what the client can pay' rule, this transaction should not proceed. Testing this interaction between rules would strengthen your test suite.
No description provided.