January 2020
Intermediate to advanced
470 pages
11h 13m
English
Given the characteristics of pure functions that we have already described, most of your unit tests could simply be the following:
Let's start with a couple of simple examples. Testing the isOldEnough() function would have been more complex than we needed for the version that required access to a global variable. On the other hand, the last version, isOldEnough3(), which didn't require anything because it received two parameters, is simple to test:
describe("isOldEnough", function() { it("is false for people younger than 18", () => { expect(isOldEnough3(1978, 1963)).toBe(false); }); it("is true for people older than ...