ByteNeurocat wrote five functions for the shop. Your job is the test suites. A suite is a function like testDiscount(applyDiscount): it receives the function under test as a parameter and declares tests.
A mini framework, like Vitest, is already loaded:
- test("name", () => { … }) declares a test (it can be async);
- expect(x).toBe(y), toEqual(y), toBeTruthy(), toBeFalsy();
- expect(() => f()).toThrow() and await expect(promise).rejects.toThrow();
- runTests(testDiscount, applyDiscount) prints a report for one function;
- huntMutants(testDiscount, "applyDiscount") runs the suite on the correct code and on every mutant.
The correct versions are available by name: applyDiscount, isValidEmail, average, withdraw, totalPrice. A step counts a suite as good if it's green on the correct code and red on every mutant.