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.

To mock or not to mock?

To mock or not to mock? - JavaScript Tutorial

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

Start my 1-month free trial

To mock or not to mock?

- Now that we've got our function working for both empty strings and simple strings, let's write a test to ensure that it works for more complicated strings with several occurrences of certain letters. Let's make another block for our test. And we're going to say that our function should return the correct letter count for words with more than one of certain letters. Now the string we're going to use to test this is the word Mississippi. M-I-S-S-I-S-S-I-P-P-I, which is the name of a river in the United States for those of you who don't know. So for our expected value, we're going to say const expected. And the word Mississippi has one m, four i's, four s's, and two p's. And for our actual value, we're going to say const actual = getLetterCount, Mississippi. And just like in our other tests, we're going to say that we expect the actual value to deep equal the expected value. So if we save this and then run our tests…

Contents