fix(curriculum): remove async wrapper around lab-weather-app tests (#63707)

This commit is contained in:
Diem-Trang Pham
2025-11-11 13:23:05 -06:00
committed by GitHub
parent 25b1397d66
commit 3d7dea735b

View File

@@ -660,28 +660,26 @@ const temp1 = fetch;
const temp2 = console.log;
const temp3 = console.error;
const temp4 = alert;
async () => {
try {
alert = () => {};
console.log = obj => {
testArr.push(obj.toString());
};
console.error = obj => {
testArr.push(obj.toString());
};
fetch = source => {
throw new Error('This is a test error');
};
await getWeather('chicago');
assert.include(testArr[0], 'This is a test error');
assert.lengthOf(testArr, 1);
} finally {
fetch = temp1;
console.log = temp2;
console.error = temp3;
alert = temp4;
}
};
try {
alert = () => {};
console.log = obj => {
testArr.push(obj.toString());
};
console.error = obj => {
testArr.push(obj.toString());
};
fetch = source => {
throw new Error('This is a test error');
};
await getWeather('chicago');
assert.include(testArr[0], 'This is a test error');
assert.lengthOf(testArr, 1);
} finally {
fetch = temp1;
console.log = temp2;
console.error = temp3;
alert = temp4;
}
```
When Paris is selected the app should show an alert with `Something went wrong, please try again later`.
@@ -689,21 +687,19 @@ When Paris is selected the app should show an alert with `Something went wrong,
```js
const testArr = [];
const temp4 = alert;
async () => {
try {
alert = msg => {
testArr.push(msg);
};
const city = 'paris';
document.querySelector('select').value = city;
document.querySelector('#get-weather-btn').click();
await new Promise(resolve => setTimeout(resolve, 1));
assert.include(testArr[0], 'Something went wrong, please try again later');
assert.lengthOf(testArr, 1);
} finally {
alert = temp4;
}
};
try {
alert = msg => {
testArr.push(msg);
};
const city = 'paris';
document.querySelector('select').value = city;
document.querySelector('#get-weather-btn').click();
await new Promise(resolve => setTimeout(resolve, 1));
assert.include(testArr[0], 'Something went wrong, please try again later');
assert.lengthOf(testArr, 1);
} finally {
alert = temp4;
}
```
# --seed--