- Clone git repo locally by running
git clone https://github.com/syldouss/poker-hands-comparator.git - Install package dependencies by running
npm iin thepoker-hands-comparatorfolder (cd poker-hands-comparator/) - Run tests with command
npm test
-
The
/src/PokerHand.jsfile contains function to create poker hand objects from string parameter andcompareWithfunction to compare a hand to another. I have implemented an error management (at least error thrown) in certain use cases (more or less than 5 cards in a hand, card value or suit not expected, etc.) -
The
/src/helper.jsfile contains helper functions used by the main entry file/src/PokerHand.js. You can find in that file thegetScorefunction used bycompareWithfunction to calculate the score of a hand in order to compare it to another hand score. You will also find here theisValidHandfunction that throws error if the given hand is not a valid poker hand (more or less than 5 cards, card value or suit not expected...).
Tests are developed using mocha and chai packages. I tried to add unit tests to all implemented functions. I say try because it's possible I forgot something.. I also tested the errors.
-
The
/test/PokerHand.test.jsfile contains unit tests that cover functions contained in/src/PokerHand.jsfile. -
The
/test/helper.test.jsfile contains unit tests that cover functions contained in/src/helper.jsfile.