Skip to content

Commit 543e804

Browse files
authored
fix(curriculum): improve rock, paper, scissors tests (freeCodeCamp#55531)
1 parent 2f4d1e3 commit 543e804

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/review-dom-manipulation-by-building-a-rock-paper-scissors-game/663d4008cee64e05dfb08f0d.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,27 @@ assert.include(possibleResults, roundResultsMsg.innerText.replace(/\//g, "'"));
4141
Your `showResults` function should update the `computerScoreSpanElement` to show the updated score of the computer.
4242

4343
```js
44-
assert.equal(computerScoreSpanElement.innerText, computerScore);
44+
computerScore = 0;
45+
const oldRandomResult = getRandomComputerResult;
46+
getRandomComputerResult = () => "Rock";
47+
48+
showResults("Scissors");
49+
assert.equal(computerScoreSpanElement.innerText, "1");
50+
51+
getRandomComputerResult = oldRandomResult;
4552
```
4653

4754
Your `showResults` function should update the `playerScoreSpanElement` to show the updated score of the player.
4855

4956
```js
50-
assert.equal(playerScoreSpanElement.innerText, playerScore);
57+
playerScore = 0;
58+
const oldRandomResult = getRandomComputerResult;
59+
getRandomComputerResult = () => "Scissors";
60+
61+
showResults("Rock");
62+
assert.equal(playerScoreSpanElement.innerText, "1");
63+
64+
getRandomComputerResult = oldRandomResult;
5165
```
5266

5367
# --seed--

curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/review-dom-manipulation-by-building-a-rock-paper-scissors-game/663d5bebe2eef6128a0b1e75.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,31 @@ Once you apply those changes, you will have completed the Rock, Paper, Scissors
2828
Your `resetGame` function should set the `playerScore` to `0`.
2929

3030
```js
31-
rockBtn.click();
31+
playerScore = 1;
3232
resetGame();
3333
assert.equal(playerScore, 0);
3434
```
3535

3636
Your `resetGame` function should set the `computerScore` to `0`.
3737

3838
```js
39-
rockBtn.click();
39+
computerScore = 1;
4040
resetGame();
4141
assert.equal(computerScore, 0);
4242
```
4343

4444
Your `resetGame` function should set the `playerScoreSpanElement` to `0`.
4545

4646
```js
47-
rockBtn.click();
47+
playerScoreSpanElement.innerText = "1";
4848
resetGame();
4949
assert.equal(playerScoreSpanElement.innerText, "0");
5050
```
5151

5252
Your `resetGame` function should set the `computerScoreSpanElement` to `0`.
5353

5454
```js
55-
rockBtn.click();
55+
computerScoreSpanElement.innerText = "1";
5656
resetGame();
5757
assert.equal(computerScoreSpanElement.innerText, "0");
5858
```
@@ -61,34 +61,39 @@ Your `resetGame` function should set the `roundResultsMsg` to an empty string.
6161

6262
```js
6363
rockBtn.click();
64+
assert.notEqual(roundResultsMsg.innerText, "");
6465
resetGame();
6566
assert.equal(roundResultsMsg.innerText, "");
6667
```
6768

6869
Your `resetGame` function should set the `winnerMsgElement` to an empty string.
6970

7071
```js
71-
rockBtn.click();
72+
winnerMsgElement.innerText = "Player has won the game!";
7273
resetGame();
7374
assert.equal(winnerMsgElement.innerText, "");
7475
```
7576

7677
Your `resetGame` function should hide the `resetGameBtn`.
7778

7879
```js
80+
playerScore = 3;
81+
computerScore = 3;
7982
rockBtn.click();
83+
assert.notEqual(window.getComputedStyle(resetGameBtn).display, "none");
8084
resetGame();
81-
const computedStyle = window.getComputedStyle(resetGameBtn).display;
82-
assert.equal(computedStyle, "none");
85+
assert.equal(window.getComputedStyle(resetGameBtn).display, "none");
8386
```
8487

8588
Your `resetGame` function should show the `optionsContainer`.
8689

8790
```js
91+
playerScore = 3;
92+
computerScore = 3;
8893
rockBtn.click();
94+
assert.equal(window.getComputedStyle(optionsContainer).display, "none");
8995
resetGame();
90-
const computedStyle = window.getComputedStyle(optionsContainer).display;
91-
assert.notEqual(computedStyle, "none");
96+
assert.notEqual(window.getComputedStyle(optionsContainer).display, "none");
9297
```
9398

9499
# --seed--

0 commit comments

Comments
 (0)