-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/add tests for statistic keeper module 406 #569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/add tests for statistic keeper module 406 #569
Conversation
…error responses from PlayerService Error was caused by `PlayerService` returning null instead of error in case the player is not found. Bug is fixed by adding if statement which returns ServiceError NOT_FOUND if the service returns null
|
Check that your husky is working, which should run prettier automatically, before the push, because there was wrong formatting in test file |
MikhailDeriabin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall good and thorough tests, some small adjustments required
| return await module.resolve(PlayerStatisticService); | ||
| } | ||
|
|
||
| static async getPlayerService() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use PlayerModule testing module to get PlayerService instead of adding a method it here. StatisticsKeeperModule should have only methods for creating own classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I do that than the mocks will not work. I think because my original solution is getting a reference to the PlayerService instance that is a dependency of the PlayerStatisticService. The purposed solution will get a reference to an another PlayerService.
|
|
||
| static async getPlayerService() { | ||
| const module = await StatisticsKeeperCommonModule.getModule(); | ||
| return await module.resolve(PlayerService); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not have to specify the await here, since it is not necessary
| it('Should increase the players playedBattles if the input is valid | PlayerEvent.BATTLE_PLAYED', async () => { | ||
| const gameStatistics = gameStatisticsBuilder.setWonBattles(0).build(); | ||
|
|
||
| const player = playerBuilder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the creation of player object into beforeEach(), since you are using this object in almost all the cases. Then remove its creation from all of the test cases
| ); | ||
|
|
||
| expect(result).toBe(false); | ||
| expect(error[0]).toBeInstanceOf(ServiceError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use the .toContainSENOT_FOUND() instead of checking the error type and its reason
…rvice.updatePlayerStatistic() tests

Brief description
Add tests for statisticKeeper module
Change list