Context:
The current pricing logic is hard to read and risky to change. There is a known bug: quantity=0 should return a total of 0, but the function currently charges for at least one item.
Goal:
Refactor the pricing logic into small, pure functions and fix the quantity=0 edge case.
Non-goals:
- No new features
- No API/signature changes for
calcPrice(input)
- No changes outside
/src/pricing/** and /tests/**
Acceptance Criteria:
calcPrice keeps the same input/output shape
- Logic is split into small functions (readable + testable)
- Tests cover: basic case,
quantity=0 edge case, and one regression scenario
npm test passes
- PR description includes: Summary, Risk/Notes, How to test
Constraints:
- Touch only:
/src/pricing/** and /tests/**
- Keep the change reviewable (small steps)
How to test:
- Run
npm test
- Example inputs:
- quantity=1, DE, no coupon
- quantity=0 (edge case)
Context:
The current pricing logic is hard to read and risky to change. There is a known bug:
quantity=0should return a total of 0, but the function currently charges for at least one item.Goal:
Refactor the pricing logic into small, pure functions and fix the
quantity=0edge case.Non-goals:
calcPrice(input)/src/pricing/**and/tests/**Acceptance Criteria:
calcPricekeeps the same input/output shapequantity=0edge case, and one regression scenarionpm testpassesConstraints:
/src/pricing/**and/tests/**How to test:
npm test