Order status
nextStatus(status, event) accepts only the state changes in the contract and refuses all others. Your tests must pass on the correct code and catch the 4 bugs.
Exercise
/**
* Next status of an order after an event.
* Allowed moves:
* - created + "pay" gives "paid".
* - created + "cancel" gives "cancelled".
* - paid + "ship" gives "shipped".
* - paid + "cancel" gives "cancelled".
* - shipped + "deliver" gives "delivered".
* Any other combination throws Error("Invalid transition").
* @param {string} status "created", "paid", "shipped", "delivered" or "cancelled".
* @param {string} event "pay", "ship", "deliver" or "cancel".
* @returns {string}
*/
function nextStatus(status, event)Your tests
0 of 4 bugs caught
- Bug 1: hidden
- Bug 2: hidden
- Bug 3: hidden
- Bug 4: hidden