FoundationsYour first tests · 2 of 5about 15 min

Every boundary, including zero

A shop charges shipping with shippingFee(total). Read the rules in the contract and write tests that catch the four bugs.

This time there are two boundaries and an error. To check that a function throws, wrap the call: expect(() => shippingFee(-1)).to.throw("Invalid total").

Before this: Guide: What to Test (and What Not To), Challenge: Test both sides of a rule

Contract

/**
 * Shipping fee for an order.
 * - Orders of 100 or more ship free (fee 0).
 * - Orders below 100 pay a fee of 10.
 * - An empty order (total 0) also pays 10.
 * - A negative total is a mistake: throws Error("Invalid total").
 * @param {number} total
 * @returns {number}
 */
function shippingFee(total)

Your tests