fix(curriculum): add test for clarifying output formatting in lab voting system (#65017)

This commit is contained in:
Aditya Singh
2026-01-08 14:13:52 +05:30
committed by GitHub
parent 05aeca4a4c
commit 87cf2f2633
@@ -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