From 98a18e981d51ced505d2df6d8b96f59c3bb7f289 Mon Sep 17 00:00:00 2001 From: Richard Halsall <–richard-glyn.halsall@informatik.hs-fulda.e> Date: Thu, 9 Feb 2023 16:04:59 +0100 Subject: [PATCH] test: testen, ob die neue Position die aktuelle Position korrekt ersetzt --- schlangen_und_leitern/js/playerHandling.js | 3 ++- .../tests/playerHandling.test.js | 23 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) 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