Skip to content

Commit

Permalink
Add tests for some weather utils (#3103)
Browse files Browse the repository at this point in the history
Co-authored-by: veeck <[email protected]>
  • Loading branch information
rejas and veeck authored May 15, 2023
1 parent 83315f1 commit 432d900
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 357 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Special thanks to @khassel, @rejas and @sdetweil for taking over most (if not al
- Added option `pastDaysCount` to default calendar module to control of how many days past events should be displayed
- Added thai language to alert module
- Added option `sendNotifications` in clock module (#3056)
- Added tests for some weather utils

### Removed

Expand Down
1 change: 1 addition & 0 deletions modules/default/weather/providers/openweathermap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/default/weather/weatherutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -40,8 +42,6 @@ const WeatherUtils = {
conversionUnit = valueUnit ? valueUnit : "mm";
}

if (valueUnit === "%") return `${convertedValue.toFixed(0)} ${conversionUnit}`;

return `${convertedValue.toFixed(2)} ${conversionUnit}`;
},

Expand Down
Loading

0 comments on commit 432d900

Please sign in to comment.