In E27: Five problems every software engineer should be able to solve, part II, you wrote a function called ziplist() that accepts two lists of equal length and returns the result of alternatingly taking elements.
Prior to starting this WOD, please:
Complete E27 if you have not already!
Ready? Let’s begin:
Start your timer.
Create a branch of your ziplist repo called “testing-1”. All your work for this WOD will be done in that branch.
Copy the mocha test runner file test.html into the top-level of your ziplist repo. This file is explained in the screencast referenced above.
Create a file called ziplist.test.js in the top-level of your ziplist repo.
Edit your test.html file to load ziplist.js and ziplist.test.js rather than sumofnumbers.js and sumofnumbers.test.js.
Using sumofnumbers.test.js as a model, write a single test for ziplist() that checks that it can merge two lists of length three correctly. You will want to refer to the Chai Behavior Driven Design API to learn about the various ways to chain assertions together.
Check that this test passes by retrieving test.html in a browser.
Now test zipListTheSimpleWay in the same way.
When the test passes and ESLint does not detect any errors, commit your branch to GitHub.
Check that your branch is on GitHub.
Stop your timer and record your time.
Rx: < 10 min Av: 10-15 min Sd: 15-20 min DNF: 20+ min
As this is extra credit, I’m not going to provide a YouTube video of the solution, but instead encourage you to watch the screencast and play around until you can get the tests to run successfully. You may be wondering what a sufficient set of tests would be for this problem? If we can always guarantee that two arrays of equal length will be passed, then it’s pretty simple: just check that the resulting list is the correct length and has the correct contents in the correct order. For example, here’s what my Mocha test.html file produces:
To be completed by the time and date indicated on the Schedule page. Submit the URL to your GitHub repo to Laulima to get credit.