From the course: JavaScript: Test-Driven Development (ES6)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Modifying existing functionality

Modifying existing functionality - JavaScript Tutorial

From the course: JavaScript: Test-Driven Development (ES6)

Start my 1-month free trial

Modifying existing functionality

- We'll we've done the red step with our failing test and the green step by making that test pass. So far we don't have anything to refactor yet, so lets go back to red and write another failing test. This time lets see if our function returns the correct object for a simple word like cat. So lets define another it lock here and we're going to say that our get letter count function should return the correct letter count for a word with only one of each letter. And inside our function here, we're going to define our expected result, which will be an object like this const expected equals C 1 A 1 T 1 and then we'll define our actual result const actual, which will be the return value of our get letter count function. When we call it with the string cat and finally we're going to make the same kind of assertion that we made in our previous test. So expect actual to deep equal expected now lets run our test to make…

Contents