mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(curriculum): add test for clarifying output formatting in lab voting system (#65017)
This commit is contained in:
@@ -276,6 +276,32 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
When option `Turkey` gets two votes, option `Morocco` gets one vote, and option `Spain` doesn't get any vote, `displayResults()` should return `"Poll Results:\nTurkey: 2 votes\nMorocco: 1 votes\nSpain: 0 votes"`.
|
||||
|
||||
```js
|
||||
const pollCopy = new Map(poll);
|
||||
try {
|
||||
poll.clear();
|
||||
addOption('Turkey');
|
||||
addOption('Morocco');
|
||||
addOption('Spain');
|
||||
|
||||
vote('Turkey', 'traveler1');
|
||||
vote('Turkey', 'traveler2');
|
||||
vote('Morocco', 'traveler3');
|
||||
|
||||
assert.equal(
|
||||
displayResults(),
|
||||
'Poll Results:\nTurkey: 2 votes\nMorocco: 1 votes\nSpain: 0 votes'
|
||||
);
|
||||
} finally {
|
||||
poll.clear();
|
||||
pollCopy.forEach((val, key) => {
|
||||
poll.set(key, val);
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
`displayResults()` should return the results in the correct format.
|
||||
|
||||
```js
|
||||
|
||||
Reference in New Issue
Block a user