improve tests (#2923)

use es6 syntax in all tests, split weather tests, remove callbacks
This commit is contained in:
Karsten Hassel
2022-10-04 10:15:24 +02:00
committed by GitHub
parent 7694d6fa86
commit f04d578704
41 changed files with 751 additions and 840 deletions

View File

@@ -3,29 +3,29 @@ const WeatherObject = require("../../../modules/default/weather/weatherobject.js
global.moment = require("moment-timezone");
global.SunCalc = require("suncalc");
describe("WeatherObject", function () {
describe("WeatherObject", () => {
let originalTimeZone;
let weatherobject;
beforeAll(function () {
beforeAll(() => {
originalTimeZone = moment.tz.guess();
moment.tz.setDefault("Africa/Dar_es_Salaam");
weatherobject = new WeatherObject("metric", "metric", "metric", true);
});
it("should return true for daytime at noon", function () {
it("should return true for daytime at noon", () => {
weatherobject.date = moment(12, "HH");
weatherobject.updateSunTime(-6.774877582342688, 37.63345667023327);
expect(weatherobject.isDayTime()).toBe(true);
});
it("should return false for daytime at midnight", function () {
it("should return false for daytime at midnight", () => {
weatherobject.date = moment(0, "HH");
weatherobject.updateSunTime(-6.774877582342688, 37.63345667023327);
expect(weatherobject.isDayTime()).toBe(false);
});
afterAll(function () {
afterAll(() => {
moment.tz.setDefault(originalTimeZone);
});
});