Test case 2 – should reject string with only spaces

Next up, it('should reject string with only spaces'). I'm going to copy that text exactly, pasting it inside of our it name. Then we can go ahead and add our arrow function (=>), and for this case what we're going to do is create a variable called response, passing in some sort of string with just spaces. We're still going to be calling isRealString, and we'll pass in a bunch of spaces. Now we're going to assert that response is false, expect(res).toBe(false), which it should be because we do not have a valid string:

it('should reject string with only spaces', () => {  var res = isRealString(' ');  expect(res).toBe(false);});

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.