mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Fixed Unit test case error for #2221
This commit is contained in:
parent
2c3e8533c7
commit
4966d6c920
@ -29,6 +29,7 @@ _This release is scheduled to be released on 2021-04-01._
|
|||||||
- Added default log levels to stop calendar log spamming.
|
- Added default log levels to stop calendar log spamming.
|
||||||
- Fix socket.io cors errors, see [breaking change since socket.io v3](https://socket.io/docs/v3/handling-cors/)
|
- Fix socket.io cors errors, see [breaking change since socket.io v3](https://socket.io/docs/v3/handling-cors/)
|
||||||
- Fix Issue with weather forecast icons due to fixed day start and end time (#2221)
|
- Fix Issue with weather forecast icons due to fixed day start and end time (#2221)
|
||||||
|
- Fix Issue with weather forecast icons unit tests with different timezones (#2221)
|
||||||
|
|
||||||
## [2.14.0] - 2021-01-01
|
## [2.14.0] - 2021-01-01
|
||||||
|
|
||||||
|
@ -355,8 +355,8 @@ Module.register("weatherforecast", {
|
|||||||
var dayEnds = 17;
|
var dayEnds = 17;
|
||||||
|
|
||||||
if (data.city && data.city.sunrise && data.city.sunset) {
|
if (data.city && data.city.sunrise && data.city.sunset) {
|
||||||
dayStarts = moment.unix(data.city.sunrise).toDate().getHours();
|
dayStarts = new Date(moment.unix(data.city.sunrise).locale("en").format("YYYY/MM/DD HH:mm:ss")).getHours();
|
||||||
dayEnds = moment.unix(data.city.sunset).toDate().getHours();
|
dayEnds = new Date(moment.unix(data.city.sunset).locale("en").format("YYYY/MM/DD HH:mm:ss")).getHours();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle different structs between forecast16 and onecall endpoints
|
// Handle different structs between forecast16 and onecall endpoints
|
||||||
@ -378,10 +378,10 @@ Module.register("weatherforecast", {
|
|||||||
var hour;
|
var hour;
|
||||||
if (forecast.dt_txt) {
|
if (forecast.dt_txt) {
|
||||||
day = moment(forecast.dt_txt, "YYYY-MM-DD hh:mm:ss").format("ddd");
|
day = moment(forecast.dt_txt, "YYYY-MM-DD hh:mm:ss").format("ddd");
|
||||||
hour = moment(forecast.dt_txt, "YYYY-MM-DD hh:mm:ss").toDate().getHours();
|
hour = new Date(moment(forecast.dt_txt).locale("en").format("YYYY-MM-DD HH:mm:ss")).getHours();
|
||||||
} else {
|
} else {
|
||||||
day = moment(forecast.dt, "X").format("ddd");
|
day = moment(forecast.dt, "X").format("ddd");
|
||||||
hour = moment(forecast.dt, "X").toDate().getHours();
|
hour = new Date(moment(forecast.dt, "X")).getHours();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (day !== lastDay) {
|
if (day !== lastDay) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* eslint no-multi-spaces: 0 */
|
/* eslint no-multi-spaces: 0 */
|
||||||
const expect = require("chai").expect;
|
const expect = require("chai").expect;
|
||||||
|
const moment = require("moment-timezone");
|
||||||
var data = require("../functions/weatherforecast_data.json");
|
var data = require("../functions/weatherforecast_data.json");
|
||||||
|
|
||||||
describe("Functions module weatherforecast", function () {
|
describe("Functions module weatherforecast", function () {
|
||||||
@ -69,6 +70,16 @@ describe("Functions module weatherforecast", function () {
|
|||||||
Log = {
|
Log = {
|
||||||
error: function () {}
|
error: function () {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var originalLocale;
|
||||||
|
var originalTimeZone;
|
||||||
|
before(function () {
|
||||||
|
originalLocale = moment.locale();
|
||||||
|
originalTimeZone = moment.tz.guess();
|
||||||
|
moment.locale("hi");
|
||||||
|
moment.tz.setDefault("Europe/Warsaw");
|
||||||
|
});
|
||||||
|
|
||||||
describe("forecastIcons sunset specified", function () {
|
describe("forecastIcons sunset specified", function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
Module.definitions.weatherforecast.Log = {};
|
Module.definitions.weatherforecast.Log = {};
|
||||||
@ -97,5 +108,10 @@ describe("Functions module weatherforecast", function () {
|
|||||||
expect(forecastData[2].icon).to.equal("wi-rain");
|
expect(forecastData[2].icon).to.equal("wi-rain");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
after(function () {
|
||||||
|
moment.locale(originalLocale);
|
||||||
|
moment.tz.setDefault(originalTimeZone);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user