mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-22 13:09:26 +00:00
Refactor common weather methods into utils class (#2958)
Co-authored-by: veeck <michael@veeck.de>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const WeatherObject = require("../../../modules/default/weather/weatherobject.js");
|
||||
const WeatherUtils = require("../../../modules/default/weather/weatherutils.js");
|
||||
|
||||
global.moment = require("moment-timezone");
|
||||
global.SunCalc = require("suncalc");
|
||||
@@ -25,15 +26,21 @@ describe("WeatherObject", () => {
|
||||
expect(weatherobject.isDayTime()).toBe(false);
|
||||
});
|
||||
|
||||
it("should convert windspeed correctly from mph to mps", () => {
|
||||
expect(Math.round(weatherobject.convertWindToMetric(93.951324266285))).toBe(42);
|
||||
});
|
||||
|
||||
it("should convert wind direction correctly from cardinal to value", () => {
|
||||
expect(weatherobject.valueWindDirection("SSE")).toBe(157);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
moment.tz.setDefault(originalTimeZone);
|
||||
});
|
||||
});
|
||||
|
||||
describe("WeatherObject", () => {
|
||||
it("should convert windspeed correctly from mph to mps", () => {
|
||||
expect(Math.round(WeatherUtils.convertWindToMetric(93.951324266285))).toBe(42);
|
||||
});
|
||||
|
||||
it("should convert windspeed correctly from kmh to mps", () => {
|
||||
expect(Math.round(WeatherUtils.convertWindToMs(151.2))).toBe(42);
|
||||
});
|
||||
|
||||
it("should convert wind direction correctly from cardinal to value", () => {
|
||||
expect(WeatherUtils.convertWindDirection("SSE")).toBe(157);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user