Ringkasan Eksekutif
Dianalisis5file
Diubah1file
Terdampak (ripple)3file
StatusAman
Dihasilkan: 1 Januari 2025 pukul 00.00
Perubahan yang Dilakukan
| File | Perubahan | Alasan |
|---|---|---|
| utils/pricing.js | Signature calculateDiscount(price, rate, callback) → async calculateDiscount(price, rate) | Modernisasi dari callback ke async/await; error kini di-throw, bukan di-forward ke callback |
| checkout.js | processCheckout(order, callback) → async processCheckout(order); konsumsi via await calculateDiscount(...) | Mengikuti signature baru pricing.js |
| report.js | Rekursi callback processNext() → Promise.all(transactions.map(tx => calculateDiscount(...))) | Lebih ringkas + paralel |
| app.js | Semua route handler function(req,res) → async (req,res) + try/catch | Menyesuaikan modul yang kini semua berbasis Promise |
| package.json | moment 2.24.0 → 2.31.0 | Patch keamanan; tidak ada breaking change di API yang dipakai |
Hasil Validasi Test
17 test17 lolos
| Test | Status | Catatan |
|---|---|---|
| menghitung grand total dengan diskon 10% | ✓ Lolos | grandTotal = 180000 |
| menghitung grand total tanpa diskon (rate 0) | ✓ Lolos | grandTotal = 50000 |
| menghitung grand total dengan diskon 100% | ✓ Lolos | grandTotal = 0 |
| melempar error jika harga negatif | ✓ Lolos | throws 'Harga tidak valid' |
| melempar error jika rate melebihi 100 | ✓ Lolos | throws 'Rate diskon tidak valid' |
| createInvoice — totalDue dengan diskon 15% | ✓ Lolos | totalDue = 425000 (setelah fix await) |
| createInvoice — tanpa diskon (0%) | ✓ Lolos | totalDue = amount asli |
| createInvoice — diskon 100% | ✓ Lolos | totalDue = 0 |
| createInvoice — properti wajib tidak undefined | ✓ Lolos | invoiceId, issuedAt, totalDue terisi |
| createInvoice — error amount negatif | ✓ Lolos | throws 'Harga tidak valid' |
| createInvoice — error rate > 100 | ✓ Lolos | throws 'Rate diskon tidak valid' |
| generateDiscountReport — akumulasi multiple transaksi | ✓ Lolos | totalOriginal/Discounted/Saved benar |
| generateDiscountReport — transaksi tunggal tanpa diskon | ✓ Lolos | totalDiscounted = amount asli |
| generateDiscountReport — diskon 100% | ✓ Lolos | totalDiscounted = 0 |
| generateDiscountReport — array kosong | ✓ Lolos | semua nilai = 0 |
| generateDiscountReport — null | ✓ Lolos | semua nilai = 0 |
| generateDiscountReport — error amount negatif | ✓ Lolos | throws 'Harga tidak valid' |