Welcome to your first day of Pairing Katas, and your first sprint!
Check out setup.md
to get started. If you're on GitHub, there's a link to it above here. If you're on VSCode, find it in the Explorer to the left.
The purpose of these exercises is to practice your TDD skills and to adjust to the idea of properly pair programming.
In your pairs, take turns being driver and navigator. Use git and the command line to handle sharing your repo, and switch to your machine when you switch drivers.
The goal of your tests is to ensure your functions return the correct output when given a range of inputs.
The most important thing to test is that your function behaves in the way it should! When you are confident that your function behaves as any reasonable user would expect it to, you should consider edge cases where the function may have to deal with extreme, unexpected, unusual or incorrect inputs - but focus on the 'happy path' first!
You are testing 'interfaces not implementations' - you care only about what your function returns when given some input. You should not try to test what exactly is happening inside the function or that people are using it in the correct way, just test that it returns the correct results for a range of different inputs.
- Follow the set-up instructions in
setup.md
. - In your katas folder you will find a
*.js
file for each problem that needs solving. You can write your solution code here. - Each kata will need a
*.test.js
file associated with it, in the__tests__
folder. You can write tests for your code here! You will need to import the function usingconst <functionName> = require('../path/to/function')
. For example:const sumDigits = require('../katas/sum-digits.js')
- Run
npm test
to run every test in your__tests__
folder. Whenever you get one or two tests done, swap your pair roles! - Below are two sets of katas for you to work on. Please do section 1 first - the order of the katas is a recommendation, but is not compulsory. However, do start with
sumDigits
as we have provided ideas for tests for this one.
- sumDigits (we've provided some ideas for tests for this one)
- countVeg
- alternateCase
- getCentury
- areOrdered
- checkUsernames
- maxAndMin
- sumArgs
- sumAscii
- getYearsOfGrowth
Note: think carefully about which Jest matcher is appropriate for each case!
- orderVeg
- checkStudents
- range
- removeDuplicates
- getDistinctLetters
- getMostRepeated
- mergeArrays
- getFrequencies
- lengthenDate
- caesarCipher
If you'd like a primer on Test Driven Development, read this blog post by Eric Elliott.