diff --git a/.eslintrc.json b/.eslintrc.json
index 4612874331..72143745db 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -27,8 +27,8 @@
"import/extensions": "error",
"import/newline-after-import": "error",
"jest/consistent-test-it": "warn",
- "jest/expect-expect": "off",
- "jest/no-done-callback": "off",
+ "jest/expect-expect": "warn",
+ "jest/no-done-callback": "warn",
"jest/prefer-expect-resolves": "warn",
"jest/prefer-mock-promise-shorthand": "warn",
"jest/prefer-to-be": "warn",
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e5ed21ec6e..f6c4f71848 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,7 +14,7 @@ _This release is scheduled to be released on 2024-01-01._
- Added updatenotification Updater (for 3rd party modules)
- Added node 21 to the test matrix
- Added transform object to calendar:customEvents
-- Added ESLint rules for jest
+- Added ESLint rules for jest (including jest/expect-expect and jest/no-done-callback)
### Removed
diff --git a/tests/e2e/animateCSS_spec.js b/tests/e2e/animateCSS_spec.js
index 91d03c176a..b9e31a7620 100644
--- a/tests/e2e/animateCSS_spec.js
+++ b/tests/e2e/animateCSS_spec.js
@@ -21,6 +21,7 @@ describe("AnimateCSS integration Test", () => {
* move similar tests in function doTest
* @param {string} [animationIn] animation in name of AnimateCSS to test.
* @param {string} [animationOut] animation out name of AnimateCSS to test.
+ * @returns {boolean} result
*/
const doTest = async (animationIn, animationOut) => {
await helpers.getDocument();
@@ -42,6 +43,7 @@ describe("AnimateCSS integration Test", () => {
} else {
expect(styles._values["animation-name"]).toBeUndefined();
}
+ return true;
};
afterEach(async () => {
@@ -51,28 +53,28 @@ describe("AnimateCSS integration Test", () => {
describe("animateIn and animateOut Test", () => {
it("with flipInX and flipOutX animation", async () => {
await helpers.startApplication(testConfigFile);
- await doTest("flipInX", "flipOutX");
+ await expect(doTest("flipInX", "flipOutX")).resolves.toBe(true);
});
});
describe("use animateOut name for animateIn (vice versa) Test", () => {
it("without animation", async () => {
await helpers.startApplication(testConfigFileInvertedAnimationName);
- await doTest();
+ await expect(doTest()).resolves.toBe(true);
});
});
describe("false Animation name test", () => {
it("without animation", async () => {
await helpers.startApplication(testConfigFileFallbackToDefault);
- await doTest();
+ await expect(doTest()).resolves.toBe(true);
});
});
describe("no Animation defined test", () => {
it("without animation", async () => {
await helpers.startApplication(testConfigByDefault);
- await doTest();
+ await expect(doTest()).resolves.toBe(true);
});
});
});
diff --git a/tests/e2e/helpers/global-setup.js b/tests/e2e/helpers/global-setup.js
index 251c55035f..592b3556a8 100644
--- a/tests/e2e/helpers/global-setup.js
+++ b/tests/e2e/helpers/global-setup.js
@@ -84,4 +84,5 @@ exports.testMatch = async (element, regex) => {
const elem = await this.waitForElement(element);
expect(elem).not.toBeNull();
expect(elem.textContent).toMatch(regex);
+ return true;
};
diff --git a/tests/e2e/helpers/weather-functions.js b/tests/e2e/helpers/weather-functions.js
index 2f84ea033e..9b55f15e6a 100644
--- a/tests/e2e/helpers/weather-functions.js
+++ b/tests/e2e/helpers/weather-functions.js
@@ -10,6 +10,7 @@ exports.getText = async (element, result) => {
.replace(/(\r\n|\n|\r)/gm, "")
.replace(/[ ]+/g, " ")
).toBe(result);
+ return true;
};
exports.startApp = async (configFileName, additionalMockData) => {
diff --git a/tests/e2e/modules/calendar_spec.js b/tests/e2e/modules/calendar_spec.js
index 71111508c6..4d1a231c5f 100644
--- a/tests/e2e/modules/calendar_spec.js
+++ b/tests/e2e/modules/calendar_spec.js
@@ -6,6 +6,7 @@ describe("Calendar module", () => {
* @param {string} element css selector
* @param {string} result expected number
* @param {string} not reverse result
+ * @returns {boolean} result
*/
const testElementLength = async (element, result, not) => {
const elem = await helpers.waitForAllElements(element);
@@ -15,12 +16,14 @@ describe("Calendar module", () => {
} else {
expect(elem).toHaveLength(result);
}
+ return true;
};
const testTextContain = async (element, text) => {
const elem = await helpers.waitForElement(element, "undefinedLoading");
expect(elem).not.toBeNull();
expect(elem.textContent).toContain(text);
+ return true;
};
afterAll(async () => {
@@ -34,11 +37,11 @@ describe("Calendar module", () => {
});
it("should show the default maximumEntries of 10", async () => {
- await testElementLength(".calendar .event", 10);
+ await expect(testElementLength(".calendar .event", 10)).resolves.toBe(true);
});
it("should show the default calendar symbol in each event", async () => {
- await testElementLength(".calendar .event .fa-calendar-alt", 0, "not");
+ await expect(testElementLength(".calendar .event .fa-calendar-alt", 0, "not")).resolves.toBe(true);
});
});
@@ -49,27 +52,27 @@ describe("Calendar module", () => {
});
it("should show the custom maximumEntries of 5", async () => {
- await testElementLength(".calendar .event", 5);
+ await expect(testElementLength(".calendar .event", 5)).resolves.toBe(true);
});
it("should show the custom calendar symbol in four events", async () => {
- await testElementLength(".calendar .event .fa-birthday-cake", 4);
+ await expect(testElementLength(".calendar .event .fa-birthday-cake", 4)).resolves.toBe(true);
});
it("should show a customEvent calendar symbol in one event", async () => {
- await testElementLength(".calendar .event .fa-dice", 1);
+ await expect(testElementLength(".calendar .event .fa-dice", 1)).resolves.toBe(true);
});
it("should show a customEvent calendar eventClass in one event", async () => {
- await testElementLength(".calendar .event.undo", 1);
+ await expect(testElementLength(".calendar .event.undo", 1)).resolves.toBe(true);
});
it("should show two custom icons for repeating events", async () => {
- await testElementLength(".calendar .event .fa-undo", 2);
+ await expect(testElementLength(".calendar .event .fa-undo", 2)).resolves.toBe(true);
});
it("should show two custom icons for day events", async () => {
- await testElementLength(".calendar .event .fa-calendar-day", 2);
+ await expect(testElementLength(".calendar .event .fa-calendar-day", 2)).resolves.toBe(true);
});
});
@@ -80,7 +83,7 @@ describe("Calendar module", () => {
});
it("should show the recurring birthday event 6 times", async () => {
- await testElementLength(".calendar .event", 6);
+ await expect(testElementLength(".calendar .event", 6)).resolves.toBe(true);
});
});
@@ -91,7 +94,7 @@ describe("Calendar module", () => {
});
it("should show the recurring event 51 times (excluded once) in a 364-day (inclusive) period", async () => {
- await testElementLength(".calendar .event", 51);
+ await expect(testElementLength(".calendar .event", 51)).resolves.toBe(true);
});
});
@@ -102,7 +105,7 @@ describe("Calendar module", () => {
});
it("should show multiple events with the same title and start time from different calendars", async () => {
- await testElementLength(".calendar .event", 22);
+ await expect(testElementLength(".calendar .event", 22)).resolves.toBe(true);
});
});
@@ -118,7 +121,7 @@ describe("Calendar module", () => {
});
it(`should contain text "Mar 25th" in timezone UTC ${-i}`, async () => {
- await testTextContain(".calendar", "Mar 25th");
+ await expect(testTextContain(".calendar", "Mar 25th")).resolves.toBe(true);
});
});
}
@@ -135,7 +138,7 @@ describe("Calendar module", () => {
});
it("should return TestEvents", async () => {
- await testElementLength(".calendar .event", 0, "not");
+ await expect(testElementLength(".calendar .event", 0, "not")).resolves.toBe(true);
});
});
@@ -146,7 +149,7 @@ describe("Calendar module", () => {
});
it("should return TestEvents", async () => {
- await testElementLength(".calendar .event", 0, "not");
+ await expect(testElementLength(".calendar .event", 0, "not")).resolves.toBe(true);
});
});
@@ -157,7 +160,7 @@ describe("Calendar module", () => {
});
it("should return TestEvents", async () => {
- await testElementLength(".calendar .event", 0, "not");
+ await expect(testElementLength(".calendar .event", 0, "not")).resolves.toBe(true);
});
});
@@ -168,7 +171,7 @@ describe("Calendar module", () => {
});
it("should return TestEvents", async () => {
- await testElementLength(".calendar .event", 0, "not");
+ await expect(testElementLength(".calendar .event", 0, "not")).resolves.toBe(true);
});
});
@@ -184,7 +187,7 @@ describe("Calendar module", () => {
});
it("should show Unauthorized error", async () => {
- await testTextContain(".calendar", "Error in the calendar module. Authorization failed");
+ await expect(testTextContain(".calendar", "Error in the calendar module. Authorization failed")).resolves.toBe(true);
});
});
});
diff --git a/tests/e2e/modules/clock_es_spec.js b/tests/e2e/modules/clock_es_spec.js
index 4bdc4bccf7..134c795b0a 100644
--- a/tests/e2e/modules/clock_es_spec.js
+++ b/tests/e2e/modules/clock_es_spec.js
@@ -13,12 +13,12 @@ describe("Clock set to spanish language module", () => {
it("shows date with correct format", async () => {
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
- await helpers.testMatch(".clock .date", dateRegex);
+ await expect(helpers.testMatch(".clock .date", dateRegex)).resolves.toBe(true);
});
it("shows time in 24hr format", async () => {
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
- await helpers.testMatch(".clock .time", timeRegex);
+ await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
});
});
@@ -30,12 +30,12 @@ describe("Clock set to spanish language module", () => {
it("shows date with correct format", async () => {
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
- await helpers.testMatch(".clock .date", dateRegex);
+ await expect(helpers.testMatch(".clock .date", dateRegex)).resolves.toBe(true);
});
it("shows time in 12hr format", async () => {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
- await helpers.testMatch(".clock .time", timeRegex);
+ await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
});
});
@@ -47,7 +47,7 @@ describe("Clock set to spanish language module", () => {
it("shows 12hr time with upper case AM/PM", async () => {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
- await helpers.testMatch(".clock .time", timeRegex);
+ await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
});
});
@@ -59,7 +59,7 @@ describe("Clock set to spanish language module", () => {
it("shows week with correct format", async () => {
const weekRegex = /^Semana [0-9]{1,2}$/;
- await helpers.testMatch(".clock .week", weekRegex);
+ await expect(helpers.testMatch(".clock .week", weekRegex)).resolves.toBe(true);
});
});
});
diff --git a/tests/e2e/modules/clock_spec.js b/tests/e2e/modules/clock_spec.js
index 03205689c7..651b20de66 100644
--- a/tests/e2e/modules/clock_spec.js
+++ b/tests/e2e/modules/clock_spec.js
@@ -14,12 +14,12 @@ describe("Clock module", () => {
it("should show the date in the correct format", async () => {
const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
- await helpers.testMatch(".clock .date", dateRegex);
+ await expect(helpers.testMatch(".clock .date", dateRegex)).resolves.toBe(true);
});
it("should show the time in 24hr format", async () => {
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
- await helpers.testMatch(".clock .time", timeRegex);
+ await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
});
});
@@ -31,12 +31,12 @@ describe("Clock module", () => {
it("should show the date in the correct format", async () => {
const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
- await helpers.testMatch(".clock .date", dateRegex);
+ await expect(helpers.testMatch(".clock .date", dateRegex)).resolves.toBe(true);
});
it("should show the time in 12hr format", async () => {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
- await helpers.testMatch(".clock .time", timeRegex);
+ await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
});
});
@@ -48,7 +48,7 @@ describe("Clock module", () => {
it("should show 12hr time with upper case AM/PM", async () => {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
- await helpers.testMatch(".clock .time", timeRegex);
+ await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
});
});
@@ -60,7 +60,7 @@ describe("Clock module", () => {
it("should show 12hr time without seconds am/pm", async () => {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
- await helpers.testMatch(".clock .time", timeRegex);
+ await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
});
});
@@ -101,7 +101,7 @@ describe("Clock module", () => {
it("should show the week in the correct format", async () => {
const weekRegex = /^Week [0-9]{1,2}$/;
- await helpers.testMatch(".clock .week", weekRegex);
+ await expect(helpers.testMatch(".clock .week", weekRegex)).resolves.toBe(true);
});
it("should show the week with the correct number of week of year", async () => {
diff --git a/tests/e2e/modules/compliments_spec.js b/tests/e2e/modules/compliments_spec.js
index e96d34f661..636a7b059a 100644
--- a/tests/e2e/modules/compliments_spec.js
+++ b/tests/e2e/modules/compliments_spec.js
@@ -4,6 +4,7 @@ describe("Compliments module", () => {
/**
* move similar tests in function doTest
* @param {Array} complimentsArray The array of compliments.
+ * @returns {boolean} result
*/
const doTest = async (complimentsArray) => {
let elem = await helpers.waitForElement(".compliments");
@@ -11,6 +12,7 @@ describe("Compliments module", () => {
elem = await helpers.waitForElement(".module-content");
expect(elem).not.toBeNull();
expect(complimentsArray).toContain(elem.textContent);
+ return true;
};
afterAll(async () => {
@@ -25,7 +27,7 @@ describe("Compliments module", () => {
});
it("shows anytime because if configure empty parts of day compliments and set anytime compliments", async () => {
- await doTest(["Anytime here"]);
+ await expect(doTest(["Anytime here"])).resolves.toBe(true);
});
});
@@ -36,7 +38,7 @@ describe("Compliments module", () => {
});
it("shows anytime compliments", async () => {
- await doTest(["Anytime here"]);
+ await expect(doTest(["Anytime here"])).resolves.toBe(true);
});
});
});
@@ -48,7 +50,7 @@ describe("Compliments module", () => {
});
it("should show compliments from a remote file", async () => {
- await doTest(["Remote compliment file works!"]);
+ await expect(doTest(["Remote compliment file works!"])).resolves.toBe(true);
});
});
});
diff --git a/tests/e2e/modules/weather_current_spec.js b/tests/e2e/modules/weather_current_spec.js
index 5ba30fc5b6..cc9ea38f52 100644
--- a/tests/e2e/modules/weather_current_spec.js
+++ b/tests/e2e/modules/weather_current_spec.js
@@ -15,15 +15,15 @@ describe("Weather module", () => {
});
it("should render wind speed and wind direction", async () => {
- await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "12 WSW");
+ await expect(weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "12 WSW")).resolves.toBe(true);
});
it("should render temperature with icon", async () => {
- await weatherFunc.getText(".weather .large.light span.bright", "1.5°");
+ await expect(weatherFunc.getText(".weather .large.light span.bright", "1.5°")).resolves.toBe(true);
});
it("should render feels like temperature", async () => {
- await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -5.6°");
+ await expect(weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -5.6°")).resolves.toBe(true);
});
});
});
@@ -34,7 +34,7 @@ describe("Weather module", () => {
});
it("should render a compliment based on the current weather", async () => {
- await weatherFunc.getText(".compliments .module-content span", "snow");
+ await expect(weatherFunc.getText(".compliments .module-content span", "snow")).resolves.toBe(true);
});
});
@@ -44,7 +44,7 @@ describe("Weather module", () => {
});
it("should render windUnits in beaufort", async () => {
- await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "6");
+ await expect(weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "6")).resolves.toBe(true);
});
it("should render windDirection with an arrow", async () => {
@@ -54,15 +54,15 @@ describe("Weather module", () => {
});
it("should render humidity", async () => {
- await weatherFunc.getText(".weather .normal.medium span:nth-child(3)", "93.7");
+ await expect(weatherFunc.getText(".weather .normal.medium span:nth-child(3)", "93.7")).resolves.toBe(true);
});
it("should render degreeLabel for temp", async () => {
- await weatherFunc.getText(".weather .large.light span.bright", "1°C");
+ await expect(weatherFunc.getText(".weather .large.light span.bright", "1°C")).resolves.toBe(true);
});
it("should render degreeLabel for feels like", async () => {
- await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C");
+ await expect(weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C")).resolves.toBe(true);
});
});
@@ -72,15 +72,15 @@ describe("Weather module", () => {
});
it("should render wind in imperial units", async () => {
- await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "26 WSW");
+ await expect(weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "26 WSW")).resolves.toBe(true);
});
it("should render temperatures in fahrenheit", async () => {
- await weatherFunc.getText(".weather .large.light span.bright", "34,7°");
+ await expect(weatherFunc.getText(".weather .large.light span.bright", "34,7°")).resolves.toBe(true);
});
it("should render 'feels like' in fahrenheit", async () => {
- await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 21,9°");
+ await expect(weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 21,9°")).resolves.toBe(true);
});
});
});
diff --git a/tests/e2e/modules/weather_forecast_spec.js b/tests/e2e/modules/weather_forecast_spec.js
index eb5dfc21de..da4c918875 100644
--- a/tests/e2e/modules/weather_forecast_spec.js
+++ b/tests/e2e/modules/weather_forecast_spec.js
@@ -16,7 +16,7 @@ describe("Weather module: Weather Forecast", () => {
const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"];
for (const [index, day] of days.entries()) {
it(`should render day ${day}`, async () => {
- await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
+ await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day)).resolves.toBe(true);
});
}
@@ -31,14 +31,14 @@ describe("Weather module: Weather Forecast", () => {
const maxTemps = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"];
for (const [index, temp] of maxTemps.entries()) {
it(`should render max temperature ${temp}`, async () => {
- await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
+ await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp)).resolves.toBe(true);
});
}
const minTemps = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"];
for (const [index, temp] of minTemps.entries()) {
it(`should render min temperature ${temp}`, async () => {
- await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp);
+ await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp)).resolves.toBe(true);
});
}
@@ -60,7 +60,7 @@ describe("Weather module: Weather Forecast", () => {
const days = ["Fri", "Sat", "Sun", "Mon", "Tue"];
for (const [index, day] of days.entries()) {
it(`should render day ${day}`, async () => {
- await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
+ await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day)).resolves.toBe(true);
});
}
});
@@ -86,7 +86,7 @@ describe("Weather module: Weather Forecast", () => {
for (const [index, precipitation] of precipitations.entries()) {
if (precipitation) {
it(`should render precipitation amount ${precipitation}`, async () => {
- await weatherFunc.getText(`.weather table tr:nth-child(${index + 1}) td.precipitation-amount`, precipitation);
+ await expect(weatherFunc.getText(`.weather table tr:nth-child(${index + 1}) td.precipitation-amount`, precipitation)).resolves.toBe(true);
});
}
}
@@ -101,7 +101,7 @@ describe("Weather module: Weather Forecast", () => {
const temperatures = ["75_9°", "69_8°", "73_2°", "74_1°", "69_1°"];
for (const [index, temp] of temperatures.entries()) {
it(`should render custom decimalSymbol = '_' for temp ${temp}`, async () => {
- await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
+ await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp)).resolves.toBe(true);
});
}
});
@@ -111,7 +111,7 @@ describe("Weather module: Weather Forecast", () => {
for (const [index, precipitation] of precipitations.entries()) {
if (precipitation) {
it(`should render precipitation amount ${precipitation}`, async () => {
- await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-amount`, precipitation);
+ await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-amount`, precipitation)).resolves.toBe(true);
});
}
}
diff --git a/tests/e2e/modules/weather_hourly_spec.js b/tests/e2e/modules/weather_hourly_spec.js
index 87fc4411cb..f61cee0546 100644
--- a/tests/e2e/modules/weather_hourly_spec.js
+++ b/tests/e2e/modules/weather_hourly_spec.js
@@ -16,7 +16,7 @@ describe("Weather module: Weather Hourly Forecast", () => {
const minTemps = ["7:00 pm", "8:00 pm", "9:00 pm", "10:00 pm", "11:00 pm"];
for (const [index, hour] of minTemps.entries()) {
it(`should render forecast for hour ${hour}`, async () => {
- await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.day`, hour);
+ await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.day`, hour)).resolves.toBe(true);
});
}
});
@@ -30,7 +30,7 @@ describe("Weather module: Weather Hourly Forecast", () => {
const minTemps = ["7:00 pm", "9:00 pm", "11:00 pm", "1:00 am", "3:00 am"];
for (const [index, hour] of minTemps.entries()) {
it(`should render forecast for hour ${hour}`, async () => {
- await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.day`, hour);
+ await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.day`, hour)).resolves.toBe(true);
});
}
});
@@ -46,7 +46,7 @@ describe("Weather module: Weather Hourly Forecast", () => {
for (const [index, amount] of amounts.entries()) {
if (amount) {
it(`should render precipitation amount ${amount}`, async () => {
- await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-amount`, amount);
+ await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-amount`, amount)).resolves.toBe(true);
});
}
}
@@ -57,7 +57,7 @@ describe("Weather module: Weather Hourly Forecast", () => {
for (const [index, pop] of propabilities.entries()) {
if (pop) {
it(`should render probability ${pop}`, async () => {
- await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-prob`, pop);
+ await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-prob`, pop)).resolves.toBe(true);
});
}
}
diff --git a/tests/e2e/translations_spec.js b/tests/e2e/translations_spec.js
index 14e6a75ce7..212d438646 100644
--- a/tests/e2e/translations_spec.js
+++ b/tests/e2e/translations_spec.js
@@ -44,74 +44,82 @@ describe("Translations", () => {
);
});
- it("should load translation file", (done) => {
- dom.window.onload = async () => {
- const { Translator, Module, config } = dom.window;
- config.language = "en";
- Translator.load = sinon.stub().callsFake((_m, _f, _fb) => null);
+ it("should load translation file", () => {
+ return new Promise((done) => {
+ dom.window.onload = async () => {
+ const { Translator, Module, config } = dom.window;
+ config.language = "en";
+ Translator.load = sinon.stub().callsFake((_m, _f, _fb) => null);
- Module.register("name", { getTranslations: () => translations });
- const MMM = Module.create("name");
+ Module.register("name", { getTranslations: () => translations });
+ const MMM = Module.create("name");
- await MMM.loadTranslations();
+ await MMM.loadTranslations();
- expect(Translator.load.args).toHaveLength(1);
- expect(Translator.load.calledWith(MMM, "translations/en.json", false)).toBe(true);
+ expect(Translator.load.args).toHaveLength(1);
+ expect(Translator.load.calledWith(MMM, "translations/en.json", false)).toBe(true);
- done();
- };
+ done();
+ };
+ });
});
- it("should load translation + fallback file", (done) => {
- dom.window.onload = async () => {
- const { Translator, Module } = dom.window;
- Translator.load = sinon.stub().callsFake((_m, _f, _fb) => null);
+ it("should load translation + fallback file", () => {
+ return new Promise((done) => {
+ dom.window.onload = async () => {
+ const { Translator, Module } = dom.window;
+ Translator.load = sinon.stub().callsFake((_m, _f, _fb) => null);
- Module.register("name", { getTranslations: () => translations });
- const MMM = Module.create("name");
+ Module.register("name", { getTranslations: () => translations });
+ const MMM = Module.create("name");
- await MMM.loadTranslations();
+ await MMM.loadTranslations();
- expect(Translator.load.args).toHaveLength(2);
- expect(Translator.load.calledWith(MMM, "translations/de.json", false)).toBe(true);
- expect(Translator.load.calledWith(MMM, "translations/en.json", true)).toBe(true);
+ expect(Translator.load.args).toHaveLength(2);
+ expect(Translator.load.calledWith(MMM, "translations/de.json", false)).toBe(true);
+ expect(Translator.load.calledWith(MMM, "translations/en.json", true)).toBe(true);
- done();
- };
+ done();
+ };
+ });
});
- it("should load translation fallback file", (done) => {
- dom.window.onload = async () => {
- const { Translator, Module, config } = dom.window;
- config.language = "--";
- Translator.load = sinon.stub().callsFake((_m, _f, _fb) => null);
+ it("should load translation fallback file", () => {
+ return new Promise((done) => {
+ dom.window.onload = async () => {
+ const { Translator, Module, config } = dom.window;
+ config.language = "--";
+ Translator.load = sinon.stub().callsFake((_m, _f, _fb) => null);
- Module.register("name", { getTranslations: () => translations });
- const MMM = Module.create("name");
+ Module.register("name", { getTranslations: () => translations });
+ const MMM = Module.create("name");
- await MMM.loadTranslations();
+ await MMM.loadTranslations();
- expect(Translator.load.args).toHaveLength(1);
- expect(Translator.load.calledWith(MMM, "translations/en.json", true)).toBe(true);
+ expect(Translator.load.args).toHaveLength(1);
+ expect(Translator.load.calledWith(MMM, "translations/en.json", true)).toBe(true);
- done();
- };
+ done();
+ };
+ });
});
- it("should load no file", (done) => {
- dom.window.onload = async () => {
- const { Translator, Module } = dom.window;
- Translator.load = sinon.stub();
+ it("should load no file", () => {
+ return new Promise((done) => {
+ dom.window.onload = async () => {
+ const { Translator, Module } = dom.window;
+ Translator.load = sinon.stub();
- Module.register("name", {});
- const MMM = Module.create("name");
+ Module.register("name", {});
+ const MMM = Module.create("name");
- await MMM.loadTranslations();
+ await MMM.loadTranslations();
- expect(Translator.load.callCount).toBe(0);
+ expect(Translator.load.callCount).toBe(0);
- done();
- };
+ done();
+ };
+ });
});
});
@@ -124,20 +132,22 @@ describe("Translations", () => {
describe("Parsing language files through the Translator class", () => {
for (let language in translations) {
- it(`should parse ${language}`, (done) => {
- const dom = new JSDOM(
- `\
+ it(`should parse ${language}`, () => {
+ return new Promise((done) => {
+ const dom = new JSDOM(
+ `\
\
+ beforeAll(() => {
+ return new Promise((done) => {
+ const dom = new JSDOM(
+ `\
\
+ beforeAll(() => {
+ return new Promise((done) => {
+ const dom = new JSDOM(
+ `\
\
+ beforeAll(() => {
+ return new Promise((done) => {
+ dom = new JSDOM(
+ `\
\
+ it("should load core translations and fallback", () => {
+ return new Promise((done) => {
+ const dom = new JSDOM(
+ `\
\
+ it("should load core fallback if language cannot be found", () => {
+ return new Promise((done) => {
+ const dom = new JSDOM(
+ `\
\
+ it("should load core translations fallback", () => {
+ return new Promise((done) => {
+ const dom = new JSDOM(
+ `\
\
+ it("should load core fallback if language cannot be found", () => {
+ return new Promise((done) => {
+ const dom = new JSDOM(
+ `\
\
+ beforeAll(() => {
+ return new Promise((done) => {
+ const dom = new JSDOM(
+ `\