-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
especially move sunset/sunrise to e2e tests
- Loading branch information
veeck
committed
Oct 19, 2022
1 parent
a9fecbe
commit cf8eb16
Showing
6 changed files
with
76 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const helpers = require("./global-setup"); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
const { generateWeather, generateWeatherForecast } = require("../../mocks/weather_test"); | ||
|
||
exports.getText = async (element, result) => { | ||
const elem = await helpers.getElement(element); | ||
await expect(elem).not.toBe(null); | ||
const text = await elem.textContent(); | ||
await expect( | ||
text | ||
.trim() | ||
.replace(/(\r\n|\n|\r)/gm, "") | ||
.replace(/[ ]+/g, " ") | ||
).toBe(result); | ||
}; | ||
|
||
exports.startApp = async (configFile, systemDate) => { | ||
let mockWeather; | ||
if (configFile.includes("forecast")) { | ||
mockWeather = generateWeatherForecast(); | ||
} else { | ||
mockWeather = generateWeather(); | ||
} | ||
let content = fs.readFileSync(path.resolve(__dirname + "../../../../" + configFile)).toString(); | ||
content = content.replace("#####WEATHERDATA#####", mockWeather); | ||
fs.writeFileSync(path.resolve(__dirname + "../../../../config/config.js"), content); | ||
await helpers.startApplication("", systemDate); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const helpers = require("../helpers/global-setup"); | ||
const weatherHelper = require("../helpers/weather-setup"); | ||
|
||
describe("Weather module", () => { | ||
afterEach(async () => { | ||
await helpers.stopApplication(); | ||
}); | ||
|
||
describe("Current weather with sunrise", () => { | ||
beforeAll(async () => { | ||
await weatherHelper.startApp("tests/configs/modules/weather/currentweather_default.js", "13 Jan 2019 00:30:00 GMT"); | ||
}); | ||
|
||
it("should render sunrise", async () => { | ||
await weatherHelper.getText(".weather .normal.medium span:nth-child(4)", "7:00 am"); | ||
}); | ||
}); | ||
|
||
describe("Current weather with sunset", () => { | ||
beforeAll(async () => { | ||
await weatherHelper.startApp("tests/configs/modules/weather/currentweather_default.js", "13 Jan 2019 12:30:00 GMT"); | ||
}); | ||
|
||
it("should render sunset", async () => { | ||
await weatherHelper.getText(".weather .normal.medium span:nth-child(4)", "3:45 pm"); | ||
}); | ||
}); | ||
}); |