Rewrite achievement tests to use a common testing function
Please complete this task first.
Testing similar code often results in tests which have the same structure. However, the coder writing the tests may not realize this until after the tests are written, at which point they have other things to do and don't want to go back and refactor the tests to remove duplication.
Our achievement tests have this problem. Most of the achievement tests seem to follow this pattern:
- Rewire some properties of the achievement module to allow for easier testing
- Create an editor
- Call a function that's expected to create an achievement
- Check that the resulting achievement object has a key with the achievement name, with values for editor ID and achievement ID
- Sometimes check that the resulting achievement object has a key with the badge name, with values for editor ID and title ID
The only things that really change here are:
- The properties of the
Achievement
module to rewire - The function to be called to generate the achievement
- The achievement and badge names
So, we'd like you to write a function that takes those as parameters, and either
a) returns a function that'll test a particular achievement b) test the achievement itself
To submit your work, clone the bookbrainz-site repository and create a new branch named "refactor-achievement-YOUR_GCI_USERNAME". Commit your changes, using small commits which make clear, self-contained changes, and using the conventions here. Finally, push your work to GitHub and create a new Pull Request.