January 2018
Beginner
658 pages
13h 10m
English
Now we'd like to do the same thing for our tests for square a number function. We'll use expect to assert that the response is indeed the number 9 and that the type is a number. We'll use these same two assertions we do with the add function. First, we need to do to delete the current square if condition code, since we will not be using that anymore. As shown in the following code, we'll make some expectations about the res variable. We'll expect it to be the number 9, just like this:
it('should square a number', () => { var res = utils.square(3); expect(res).toBe(9);});
We'll save the file and make sure the test passes, and it does indeed pass:
Now, we'll assert the type using toBeA. Here, we're ...
Read now
Unlock full access