Refactor common weather methods into utils class (#2958)

Co-authored-by: veeck <michael@veeck.de>
This commit is contained in:
Veeck
2022-10-28 19:56:55 +02:00
committed by GitHub
parent dde88601a6
commit c191ff0032
9 changed files with 133 additions and 114 deletions

View File

@@ -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);
});
});