This is a NodeJS implementation of a fruit basket order Kata.
- git clone this repo
- npm install
- npm test
- npm start
We are a national supermarket chain that is interested in starting to use special offers in our stores. We stock the following products:
Item | Price (💷 £) |
---|---|
🍎 Apple | 0.20 |
🍊 Orange | 0.50 |
🍉 Watermelon | 0.80 |
We would like to allow the following special offers:
- Buy One Get One Free on Apples
- Three For The Price Of Two on Watermelons
We would like to see the output for an example basket 🛒 containing the following items:
Item | Quantity |
---|---|
🍎 Apple | 4 |
🍊 Orange | 3 |
🍉 Watermelon | 5 |
- There is no requirements for any user interface - a command-line program is fine
- You can use any programming language that you like
- Applied Test-Driven Development;
- Used Strategy Pattern for the discounts, etc.;
- Did have to refactor midway through because I did not understood "Buy 1 Get 1 Free" correctly, but it was easy with the existing 100% code coverage and good architecture given as a bonus of doing TDD;
- Used Jest as a test runner;
- made it in less than 2 hours.
- Maybe I should have given the total discount instead of the total resulting price to enable the UI to give more insights to the end-user, but it can be quickly added given the architecture & code-coverage: refactoring or adding features is easy and safe!
This is a finished project, but I did continue to play around to test Github Actions to setup a CI/CD to build, test, and report code coverage.
Also added a few README badges along the way.
Added a Travis CI build (install, test, etc.) seeCI replaced with Github Actions.travis.yml
file- with code coverage reporting via Coveralls
- and dependency vulnerability analysis via Snyk
- and code quality analysis via Code Climate
- mutation testing with Stryker, which helped me refine tests and unused code.
Also, to compare with I added a Github Actions Workflow that almost does the same (see .github/main.workflow
file):
- install
- test
- start
- check prettier
- report code coverage
(Still missing the Code Climate integration)
See LICENSE