From 1dc0a0d5b56d002c7fba491a00181d289ceb7e6f Mon Sep 17 00:00:00 2001 From: Veeck Date: Tue, 7 Feb 2023 00:03:08 +0100 Subject: [PATCH] Update some tests (#3024) Co-authored-by: veeck --- CHANGELOG.md | 2 +- tests/electron/modules/calendar_spec.js | 9 +++------ tests/unit/functions/weather_object_spec.js | 9 +++++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3964da9c..b106df49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ _This release is scheduled to be released on 2023-04-01._ - Update issue template and contributing doc - The weather modules clearly separates precipation amount and probability (risk of rain/snow) - This requires all providers that only supports probability to change the config from `showPrecipitationAmount` to `showPrecipitationProbability`. -- Update weather tests +- Update tests for weather and calendar module - Changed updatenotification module for MagicMirror repo only: Send only notifications for `master` if there is a tag on a newer commit - Update dates in Calendar widgets every minute diff --git a/tests/electron/modules/calendar_spec.js b/tests/electron/modules/calendar_spec.js index e2941d44..755a6bff 100644 --- a/tests/electron/modules/calendar_spec.js +++ b/tests/electron/modules/calendar_spec.js @@ -7,11 +7,8 @@ describe("Calendar module", () => { * @param {string} cssClass css selector */ const doTest = async (cssClass) => { - await helpers.getElement(".calendar"); - await helpers.getElement(".module-content"); - const events = await global.page.locator(".event"); - const elem = await events.locator(cssClass); - expect(elem).not.toBe(null); + let elem = await helpers.getElement(".calendar .module-content .event" + cssClass); + expect(await elem.isVisible()).toBe(true); }; afterEach(async () => { @@ -25,7 +22,7 @@ describe("Calendar module", () => { }); it("has css class tomorrow", async () => { - await helpers.startApplication("tests/configs/modules/calendar/custom.js", "31 Dez 2029 12:30:00 GMT"); + await helpers.startApplication("tests/configs/modules/calendar/custom.js", "31 Dec 2029 12:30:00 GMT"); await doTest(".tomorrow"); }); }); diff --git a/tests/unit/functions/weather_object_spec.js b/tests/unit/functions/weather_object_spec.js index a381547f..ee6578af 100644 --- a/tests/unit/functions/weather_object_spec.js +++ b/tests/unit/functions/weather_object_spec.js @@ -49,6 +49,11 @@ describe("WeatherObject", () => { }); describe("WeatherUtils", () => { + it("should convert windspeed correctly from mps to beaufort", () => { + expect(Math.round(WeatherUtils.convertWind(5, "beaufort"))).toBe(3); + expect(Math.round(WeatherUtils.convertWind(42, "beaufort"))).toBe(12); + }); + it("should convert windspeed correctly from mph to mps", () => { expect(Math.round(WeatherUtils.convertWindToMetric(93.951324266285))).toBe(42); }); @@ -64,4 +69,8 @@ describe("WeatherUtils", () => { it("should return a calculated feelsLike info", () => { expect(WeatherUtils.calculateFeelsLike(0, 20, 40)).toBe(-9.444444444444445); }); + + it("should return a calculated feelsLike info", () => { + expect(WeatherUtils.calculateFeelsLike(30, 0, 60)).toBe(32.8320322777777); + }); });