Add test#320
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
The test file has critical gaps in coverage. Only one test case exists, but the task requires testing all six rules. Missing tests for: (2) tank capacity overflow handling, (3) client payment limit constraints, (4) rounding poured amount to tenth, (5) minimum 2-liter threshold, and (6) price rounding to hundredth. Additionally, there's an empty placeholder test it('should ') that should be removed. All six functional rules from the requirements must have corresponding test cases before this can be approved.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| // const { fillTank } = require('./fillTank'); | ||
| const { fillTank } = require('./fillTank'); | ||
|
|
||
| it('should ', () => {}); |
There was a problem hiding this comment.
Remove this empty placeholder test or replace it with a meaningful test case
| it('should fill full tank when amount is not provided', () => { | ||
| const customer = { | ||
| money: 1000, | ||
| vehicle: { maxTankCapacity: 40, fuelRemains: 10 }, | ||
| }; | ||
|
|
||
| fillTank(customer, 10); | ||
|
|
||
| expect(customer.vehicle.fuelRemains).toBe(40); | ||
| expect(customer.money).toBe(700); |
There was a problem hiding this comment.
Add tests for rule #2: when amount exceeds tank capacity, should pour only what fits
| it('should fill full tank when amount is not provided', () => { | ||
| const customer = { | ||
| money: 1000, | ||
| vehicle: { maxTankCapacity: 40, fuelRemains: 10 }, | ||
| }; | ||
|
|
||
| fillTank(customer, 10); | ||
|
|
||
| expect(customer.vehicle.fuelRemains).toBe(40); | ||
| expect(customer.money).toBe(700); |
There was a problem hiding this comment.
Add tests for rule #3: should always fill only what client can afford to pay
| it('should fill full tank when amount is not provided', () => { | ||
| const customer = { | ||
| money: 1000, | ||
| vehicle: { maxTankCapacity: 40, fuelRemains: 10 }, | ||
| }; | ||
|
|
||
| fillTank(customer, 10); | ||
|
|
||
| expect(customer.vehicle.fuelRemains).toBe(40); | ||
| expect(customer.money).toBe(700); |
There was a problem hiding this comment.
Add tests for rule #4: verify poured amount is rounded down to tenth part (e.g., 15.37L becomes 15.3L)
| it('should fill full tank when amount is not provided', () => { | ||
| const customer = { | ||
| money: 1000, | ||
| vehicle: { maxTankCapacity: 40, fuelRemains: 10 }, | ||
| }; | ||
|
|
||
| fillTank(customer, 10); | ||
|
|
||
| expect(customer.vehicle.fuelRemains).toBe(40); | ||
| expect(customer.money).toBe(700); |
There was a problem hiding this comment.
Add tests for rule #5: if poured amount is less than 2 liters, do not pour at all
| it('should fill full tank when amount is not provided', () => { | ||
| const customer = { | ||
| money: 1000, | ||
| vehicle: { maxTankCapacity: 40, fuelRemains: 10 }, | ||
| }; | ||
|
|
||
| fillTank(customer, 10); | ||
|
|
||
| expect(customer.vehicle.fuelRemains).toBe(40); | ||
| expect(customer.money).toBe(700); |
There was a problem hiding this comment.
Add tests for rule #6: verify price is rounded to nearest hundredth part
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your solution is approved. The test file now comprehensively covers all six functional requirements for the fillTank function, including edge cases for full tank scenarios, capacity limits, payment constraints, rounding behavior, and price calculations. All previously missing test cases have been successfully added and validated. The only noted issue is a low-priority test case that expects NaN values, which doesn't affect the core functionality being tested. Great work implementing a complete test suite!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
qa_fill-tank.git