fix: add TCO unit tests and fix blocking issues (refs #15)
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 4m34s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 28s
Deploy to Staging / Verify Staging (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 6s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 4m34s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 28s
Deploy to Staging / Verify Staging (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 6s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
Quality Review Fixes: - Add comprehensive unit tests for getTCO() method (12 test cases) - Add tests for normalizeRecurringCost() via getTCO integration - Add future date validation guard in calculateMonthsOwned() - Fix pre-existing unused React import in VehicleLimitDialog.test.tsx - Fix pre-existing test parameter types in vehicles.service.test.ts Test Coverage: - Vehicle not found / unauthorized access - Missing optional TCO fields handling - Zero odometer (costPerDistance = 0) - Monthly/semi-annual/annual cost normalization - Division by zero guard (new purchase) - Future purchase date handling 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -482,6 +482,10 @@ export class VehiclesService {
|
||||
private calculateMonthsOwned(purchaseDate: string): number {
|
||||
const purchase = new Date(purchaseDate);
|
||||
const now = new Date();
|
||||
// Guard against future dates - treat as 0 months owned
|
||||
if (purchase > now) {
|
||||
return 0;
|
||||
}
|
||||
const yearDiff = now.getFullYear() - purchase.getFullYear();
|
||||
const monthDiff = now.getMonth() - purchase.getMonth();
|
||||
return yearDiff * 12 + monthDiff;
|
||||
|
||||
Reference in New Issue
Block a user