Thousand Card Game: How about quality?
What is this project about?
This contribution is made to gornanization/1k. If you would like to find more info - I strongly recommend reading this post first.
PR:
https://github.com/gornanization/1k/pull/23
Details
It’s good time to focus on unit testing. Within the contribution, code coverage (coveralls) has been added to the project. So officially we do know the number representing code coverage of 1k. It’s 75%. Not as good as we expect. We would love to increase this number so for sure a new set of unit tests will be implemented soon.
But, do we have to provide unit tests for each line of code? Nope. So which lines might be skipped? Let’s review what code categories we have in our codebase:
- validator functions: As prefixed with
canorisfunction names suggests - it decides whether we are able to perform some further action based on game state, passed as an argument. Examples? Here you are:canThrowCard,canRegister,isGameFinished,isTrickFinished(by the way, I was describing it here some time ago). - helper functions: set of helper function, which retrives specific informations for us. Examples:
getTrickWinner,createDeck,getTrumpPointsBySuit,getCardWithHighestRank. - reducer: As our codebase is powered by Flux approach (Redux), the whole logic standing behind process of changing game state is implemented in a reducer.
- actions: Also a part of Redux, it’s a set of functions, which creates action object. Examples:
throwCard,bid,registerPlayer,declareBomb. - public API logic: This is a place when validators, helper functions, actions are link together to give fully working API capabilities.
So, do we have to test helper functions directly? We don’t. We test it indirectly, by testing reducer and validation functions. How about actions? We test it indirectly, through reducer, so no need to write separated unit tests for it. Testing validation is important. We do not want the player to throw card which he does not own, right? According to public API. We will test it as well, to provide proper transition between phases, which is extremely crucial. You can expect more unit tests soon. Greetings for all players!
Take care people!
Posted on Utopian.io - Rewarding Open Source Contributors



Dont stop please...
Wondergull
Congratulations @adasq! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOPThank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Hey @adasq I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x
You got a 3.26% upvote from @upme requested by: @adasq.
Send at least 1 SBD to @upme with a post link in the memo field to receive upvote next round.
To support our activity, please vote for my master @suggeelson, as a STEEM Witness