Browse Source

test: testen, ob die neue Position die aktuelle Position korrekt ersetzt

main
Richard Halsall 2 years ago
parent
commit
98a18e981d
  1. 3
      schlangen_und_leitern/js/playerHandling.js
  2. 23
      schlangen_und_leitern/tests/playerHandling.test.js

3
schlangen_und_leitern/js/playerHandling.js

@ -219,5 +219,6 @@ module.exports = {
buildPlayerArray, buildPlayerArray,
movePlayer, movePlayer,
over100, over100,
landedOn
landedOn,
resetNewOld
} }

23
schlangen_und_leitern/tests/playerHandling.test.js

@ -4,7 +4,8 @@ PlayerBuilder,
buildPlayerArray, buildPlayerArray,
movePlayer, movePlayer,
over100, over100,
landedOn
landedOn,
resetNewOld
} = require('../js/playerHandling'); } = require('../js/playerHandling');
let player = {"position": 1, "newPosition": 1, "won": false}; let player = {"position": 1, "newPosition": 1, "won": false};
@ -106,3 +107,23 @@ describe('tests testen', () => {
}); });
}) })
describe('testen, ob die neue Position die aktuelle Position ersetzt ', () => {
it('mit einer Zufallszahl von 1 bis 100 zwanzigmal', ()=>{
for(let i = 0; i <= 20; i++)
{
min = Math.ceil(1);
max = Math.floor(100);
let position = Math.floor(Math.random() * (max - min + 1) + min)
let player = {"position": 1, "newPosition": position, "won": false}
resetNewOld(player);
expect(player).toEqual({"position": position, "newPosition": 0, "won": false});
}
});
})
Loading…
Cancel
Save