Client Feature — Unit Tests

Pure logic tests (no network calls)

✓

All tests passing

24 / 24 passed

✓
getClientInvoices: matches by email when email present
✓
getClientInvoices: falls back to name match when no email
✓
getClientInvoices: returns empty for unknown client
✓
filterClients: filters by name (case-insensitive)
✓
filterClients: filters by email
✓
filterClients: filters by phone
✓
filterClients: empty search returns all
✓
filterClients: no match returns empty
✓
calculateRevenue: totalRevenue only sums paid invoices
✓
calculateRevenue: totalInvoiced sums all invoices
✓
calculateRevenue: pendingAmount sums pending + overdue balance_due
✓
calculateRevenue: returns zeros for empty invoices
✓
calculateInvoiceTotals: subtotal sums item totals
✓
calculateInvoiceTotals: VAT at 7.5% applied correctly
✓
calculateInvoiceTotals: VAT not applied when apply_vat=false
✓
calculateInvoiceTotals: advance payment reduces balance_due
✓
calculateInvoiceTotals: balance_due cannot go negative
✓
isClientFieldFilled: true when buyer_name filled
✓
isClientFieldFilled: true when only email filled
✓
isClientFieldFilled: false when all empty
✓
selectClientFillsForm: maps all fields correctly
✓
selectClientFillsForm: handles missing fields gracefully
✓
Remind button shown only for pending/overdue
✓
Remind button disabled when no buyer_email