fix(curriculum): add missing dispatchEvent (#55216)

This commit is contained in:
Krzysztof G
2024-06-19 08:06:53 +02:00
committed by GitHub
parent c8c0618e1e
commit 32fbef544c
3 changed files with 7 additions and 0 deletions
@@ -68,6 +68,7 @@ let alertMessage;
window.alert = (message) => alertMessage = message; // Override alert and store message
inputEl.value = '';
inputEl.dispatchEvent(new Event('change'))
checkBtn.click();
assert.strictEqual(alertMessage.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'please input a value');
```
@@ -259,6 +260,7 @@ const fourthLetter = characters.charAt(Math.floor(Math.random() * charactersLeng
const phrase = firstLetter + secondLetter + thirdLetter + fourthLetter + fourthLetter + thirdLetter + secondLetter + firstLetter;
inputEl.value = phrase;
inputEl.dispatchEvent(new Event('change'))
checkBtn.click();
assert.strictEqual(resultEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), phrase + ' is a palindrome');
@@ -298,6 +300,7 @@ charactersLength--;
const phrase = firstLetter + secondLetter + thirdLetter + fourthLetter;
inputEl.value = phrase;
inputEl.dispatchEvent(new Event('change'))
checkBtn.click();
assert.strictEqual(resultEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), phrase + ' is not a palindrome');
@@ -378,6 +378,7 @@ async () => {
const randomInvalidPokeId = badName;
searchInput.value = randomInvalidPokeId;
searchInput.dispatchEvent(new Event('change'));
searchButton.click();
const res = await fetch('https://pokeapi-proxy.freecodecamp.rocks/api/pokemon/' + randomInvalidPokeId.toString()); // Fetch from proxy to simulate network delay
@@ -406,6 +407,7 @@ async () => {
const randomValidPokeId = Math.floor(Math.random() * 1025) + 1;
searchInput.value = randomValidPokeId;
searchInput.dispatchEvent(new Event('change'));
searchButton.click();
const res = await fetch('https://pokeapi-proxy.freecodecamp.rocks/api/pokemon/' + randomValidPokeId.toString()); // Fetch from proxy to simulate network delay
@@ -180,6 +180,7 @@ const outputEl = document.getElementById('output');
const randomNegativeNumber = Math.floor(Math.random() * -4000) - 2;
numberInputEl.value = randomNegativeNumber;
numberInputEl.dispatchEvent(new Event('change'));
convertBtnEl.click();
assert.strictEqual(outputEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'please enter a number greater than or equal to 1');
```
@@ -194,6 +195,7 @@ const outputEl = document.getElementById('output');
const randomBigNumber = Math.floor(Math.random() * (1000000)) + 4000;
numberInputEl.value = randomBigNumber;
numberInputEl.dispatchEvent(new Event('change'));
convertBtnEl.click();
assert.strictEqual(outputEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'please enter a number less than or equal to 3999');
```