FoundationsYour first tests · 5 of 5about 20 min

What can happen, and what cannot

nextStatus(status, event) moves an order from one state to the next. The contract lists the allowed moves; every other combination is an error.

Write tests for the allowed transitions and for forbidden ones. A bug that allows a move it should refuse stays hidden unless a test tries exactly that move.

Before this: Challenge: Every combination of conditions

Contract

/**
 * 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