itaditya / trick-or-treat-game

Play it for free here
https://trick-or-treat.netlify.com/
16 stars 17 forks source link

Movementtests #10

Closed flagoon closed 5 years ago

flagoon commented 5 years ago

Hey, I added some tests for movement. We have 90% coverage for your application :) I think I found good solution for testing user position after the change. I just wonder, if comparing to the string '5-5' is a better option than comparing to the calculated position (Math.floor...). Then I would just compare to variable like: initialPosX - 1 etc. Not sure what you think. Current solution works for this board, but if you decide to increase the game board, then tests needs to be remade.

flagoon commented 5 years ago

I also don't know (for now) how to 'mock' user position, to check if the movement counter is increased, or if sprite number is decreased. I'll take care of this tomorrow or day after tomorrow.

itaditya commented 5 years ago

Since we know boardSizeX and boardSizeY we can just half them and that will give the initial user position for any board size. @flagoon do you have some free time to work on this now?

Using the key to find out newUserPos is a genius idea. I just have one confusion about this. Should we tie a react internal feature as a requirement to also make test work?