Write tests that cover each branch and edge case. Test success paths, error paths, and boundary conditions.
function processPayment(amount, method) {
if (amount <= 0) return { success: false, error: 'Invalid amount' };
if (method === 'credit') return { success: true, charge: amount };
if (method === 'debit') return { success: true, charge: amount };
return { success: false, error: 'Unknown method' };
}
// ...Write tests that cover each branch and edge case. Test success paths, error paths, and boundary conditions.
function processPayment(amount, method) {
if (amount <= 0) return { success: false, error: 'Invalid amount' };
if (method === 'credit') return { success: true, charge: amount };
if (method === 'debit') return { success: true, charge: amount };
return { success: false, error: 'Unknown method' };
}
// ...