mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-07-18 12:49:00 +00:00
refactor: extract constants for weather electron tests (#3845)
I find the tests with clear variable names much easier to understand.
This commit is contained in:
parent
7f8935a34c
commit
02e76da196
@ -19,6 +19,7 @@ Thanks to: @dathbe.
|
|||||||
- [core] Enhance system information logging format and include additional env and RAM details (#3839, #3843)
|
- [core] Enhance system information logging format and include additional env and RAM details (#3839, #3843)
|
||||||
- [refactor] Add new file `js/module_functions.js` to move code used in several modules to one place (#3837)
|
- [refactor] Add new file `js/module_functions.js` to move code used in several modules to one place (#3837)
|
||||||
- [tests] refactor: simplify jest config file (#3844)
|
- [tests] refactor: simplify jest config file (#3844)
|
||||||
|
- [tests] refactor: extract constants for weather electron tests (#3845)
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
||||||
|
@ -2,6 +2,13 @@ const helpers = require("../helpers/global-setup");
|
|||||||
const weatherHelper = require("../helpers/weather-setup");
|
const weatherHelper = require("../helpers/weather-setup");
|
||||||
const { cleanupMockData } = require("../../utils/weather_mocker");
|
const { cleanupMockData } = require("../../utils/weather_mocker");
|
||||||
|
|
||||||
|
const CURRENT_WEATHER_CONFIG = "tests/configs/modules/weather/currentweather_default.js";
|
||||||
|
const SUNRISE_DATE = "13 Jan 2019 00:30:00 GMT";
|
||||||
|
const SUNSET_DATE = "13 Jan 2019 12:30:00 GMT";
|
||||||
|
const SUN_EVENT_SELECTOR = ".weather .normal.medium span:nth-child(4)";
|
||||||
|
const EXPECTED_SUNRISE_TEXT = "7:00 am";
|
||||||
|
const EXPECTED_SUNSET_TEXT = "3:45 pm";
|
||||||
|
|
||||||
describe("Weather module", () => {
|
describe("Weather module", () => {
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await helpers.stopApplication();
|
await helpers.stopApplication();
|
||||||
@ -10,21 +17,23 @@ describe("Weather module", () => {
|
|||||||
|
|
||||||
describe("Current weather with sunrise", () => {
|
describe("Current weather with sunrise", () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await weatherHelper.startApp("tests/configs/modules/weather/currentweather_default.js", "13 Jan 2019 00:30:00 GMT");
|
await weatherHelper.startApp(CURRENT_WEATHER_CONFIG, SUNRISE_DATE);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render sunrise", async () => {
|
it("should render sunrise", async () => {
|
||||||
await expect(weatherHelper.getText(".weather .normal.medium span:nth-child(4)", "7:00 am")).resolves.toBe(true);
|
const isSunriseRendered = await weatherHelper.getText(SUN_EVENT_SELECTOR, EXPECTED_SUNRISE_TEXT);
|
||||||
|
expect(isSunriseRendered).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Current weather with sunset", () => {
|
describe("Current weather with sunset", () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await weatherHelper.startApp("tests/configs/modules/weather/currentweather_default.js", "13 Jan 2019 12:30:00 GMT");
|
await weatherHelper.startApp(CURRENT_WEATHER_CONFIG, SUNSET_DATE);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render sunset", async () => {
|
it("should render sunset", async () => {
|
||||||
await expect(weatherHelper.getText(".weather .normal.medium span:nth-child(4)", "3:45 pm")).resolves.toBe(true);
|
const isSunsetRendered = await weatherHelper.getText(SUN_EVENT_SELECTOR, EXPECTED_SUNSET_TEXT);
|
||||||
|
expect(isSunsetRendered).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user