January 2018
Beginner
658 pages
13h 10m
English
The assertions will be done using the expect library. We'll make some assertions about the res variable. We'll assert that it equals, using toBe, the number 25, which is 5 times 5. We'll also use toBeA to assert something about the type of the value:
it('should async square a number', (done) => { utils.asyncSquare(5, (res) => { expect(res).toBe(25).toBeA('number'); });});
In this case, we want to make sure that the square is indeed a number, as opposed to a Boolean, string, or object. With this in place, we do need to call done and then save the file:
it('should async square a number', (done) => { utils.asyncSquare(5, (res) => { expect(res).toBe(25).toBeA('number'); done(); });});