Add tests for some weather utils (#3103)

Co-authored-by: veeck <michael@veeck.de>
This commit is contained in:
Veeck
2023-05-15 21:04:50 +02:00
committed by GitHub
parent 83315f1fed
commit 432d900ecd
7 changed files with 227 additions and 357 deletions

View File

@@ -434,6 +434,7 @@ WeatherProvider.register("openweathermap", {
} else if (this.firstEvent && this.firstEvent.location) {
params += `q=${this.firstEvent.location}`;
} else {
// TODO hide doesnt exist!
this.hide(this.config.animationSpeed, { lockString: this.identifier });
return;
}

View File

@@ -30,6 +30,8 @@ const WeatherUtils = {
* @returns {string} - A string with tha value and a unit postfix.
*/
convertPrecipitationUnit(value, valueUnit, outputUnit) {
if (valueUnit === "%") return `${value.toFixed(0)} ${valueUnit}`;
let convertedValue = value;
let conversionUnit = valueUnit;
if (outputUnit === "imperial") {
@@ -40,8 +42,6 @@ const WeatherUtils = {
conversionUnit = valueUnit ? valueUnit : "mm";
}
if (valueUnit === "%") return `${convertedValue.toFixed(0)} ${conversionUnit}`;
return `${convertedValue.toFixed(2)} ${conversionUnit}`;
},