- You are not allowed to write any production code unless it is to make a failing unit test pass.
- You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
- You are not allowed to write any more production code than is sufficient to pass the one failing unit test.
Which means the workflow is:
- Write a failing test. Stop writing the test as soon as it fails.
- Write the minimal production code required for the test to pass. Stop writing any code once the test passes.
- Refactor the test code and the production code without altering the functionality. All tests should pass.
To run the tests, run npm run test.
- Try not to read ahead.
- Do one task at a time. The trick is to learn to work incrementally.
This kata demonstrates the problems of static scoped functions and objects.
All tests should always pass, regardless of environment conditions.
- Write a
Greeterclass withgreetfunction that receives anameas input and outputsHello <name>. The signature ofgreetshould not change throughout the kata. You are allowed to constructGreeterobject as you please. greetcapitalizes the first letter of the namegreetreturnsGood morning <name>when the time is 06:00-12:00greetreturnsGood evening <name>when the time is 18:00-22:00greetreturnsGood night <name>when the time is 22:00-06:00greetlogs into console each time it is called