diff --git a/schlangen_und_leitern/js/playerHandling.js b/schlangen_und_leitern/js/playerHandling.js index 338ab0d..8906dec 100644 --- a/schlangen_und_leitern/js/playerHandling.js +++ b/schlangen_und_leitern/js/playerHandling.js @@ -219,5 +219,6 @@ module.exports = { buildPlayerArray, movePlayer, over100, - landedOn + landedOn, + resetNewOld } \ No newline at end of file diff --git a/schlangen_und_leitern/tests/playerHandling.test.js b/schlangen_und_leitern/tests/playerHandling.test.js index 7efc993..2889182 100644 --- a/schlangen_und_leitern/tests/playerHandling.test.js +++ b/schlangen_und_leitern/tests/playerHandling.test.js @@ -4,7 +4,8 @@ PlayerBuilder, buildPlayerArray, movePlayer, over100, -landedOn +landedOn, +resetNewOld } = require('../js/playerHandling'); let player = {"position": 1, "newPosition": 1, "won": false}; @@ -105,4 +106,24 @@ 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}); + } + + }); + }) \ No newline at end of file