This pull request is the first of many that will add test cases for different parts of the system. The first part I chose to add tests for was the reporter. This includes both the postWeek and postRecap functions.
One thing to note is that when testing the week will always be 10. This allows us to use static text in the test cases to compare against, rather than dynamic. I think this will provide better results because in the case that the dynamic week is broken, it will be both broken in the tests and outside of the tests and therefore the tests may still pass and let broken code through.
Tests were added for the following functions: initializeReport, leaderboard, contestants, payout, spotify, getNumVotes. More will come in the future, as will better test reporting both locally and in shippable. Note that shippable does not capture the results of the tests nor does it get the code coverage. These are both issues that need to be addressed.
It should look more like:
A new function initializeReport(users: User[], postWeek = false) has been added to make it easier to create a new report. There is an optional parameter postWeek which defaults to false. Use it like this:
const postRecap = initializeReport(users) OR initializeReport(users, false)
const postWeek = initializeReport(users, true)
The output of the current tests when running jest should look like this:
Check out the #nowplaying community and bot in action here