MagicMirror/tests/mocks/weather_test.js
Michael Teeuw 0300ce05d5
Release 2.22.0 (#2983)
## [2.22.0] - 2023-01-01

Thanks to: @angeldeejay, @buxxi, @dariom, @dWoolridge,
@KristjanESPERANTO, @MagMar94, @naveensrinivasan, @retroflex, @SkySails
and @Tom.

Special thanks to @khassel, @rejas and @sdetweil for taking over most
(if not all) of the work on this release as project collaborators. This
version would not be there without their effort. Thank you!

### Added

- Added test for remoteFile option in compliments module
- Added hourlyWeather functionality to Weather.gov weather provider
- Removed weatherEndpoint definition from weathergov.js (not used)
- Added css class names "today" and "tomorrow" for default calendar
- Added Collaboration.md
- Added new github action for dependency review (#2862)
- Added a WeatherProvider for Open-Meteo
- Added Yr as a weather provider
- Added config options "ignoreXOriginHeader" and
"ignoreContentSecurityPolicy"

### Removed

- Removed usage of internal fetch function of node until it is more
stable

### Updated

- Cleaned up test directory (#2937) and jest config (#2959)
- Wait for all modules to start before declaring the system ready
(#2487)
- Updated e2e tests (moved `done()` in helper functions) and use es6
syntax in all tests
- Updated da translation
- Rework weather module
- Make sure smhi provider api only gets a maximum of 6 digits
coordinates (#2955)
  - Use fetch instead of XMLHttpRequest in weatherprovider (#2935)
  - Reworked how weatherproviders handle units (#2849)
  - Use unix() method for parsing times, fix suntimes on the way (#2950)
  - Refactor conversion functions into utils class (#2958)
- The `cors`-method in `server.js` now supports sending and recieving
HTTP headers
- Replace `…` by `…`
- Cleanup compliments module
- Updated dependencies including electron to v22 (#2903)

### Fixed

- Correctly show apparent temperature in SMHI weather provider
- Ensure updatenotification module isn't shown when local is _ahead_ of
remote
- Handle node_helper errors during startup (#2944)
- Possibility to change FontAwesome class in calendar, so icons like
`fab fa-facebook-square` works.
- Fix cors problems with newsfeed articles (as far as possible), allow
disabling cors per feed with option `useCorsProxy: false` (#2840)
- Tests not waiting for the application to start and stop before
starting the next test
- Fix electron tests failing sometimes in github workflow
- Fixed gap in clock module when displayed on the left side with
displayType=digital
- Fixed playwright issue by upgrading to v1.29.1 (#2969)

Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
Co-authored-by: Karsten Hassel <hassel@gmx.de>
Co-authored-by: Malte Hallström <46646495+SkySails@users.noreply.github.com>
Co-authored-by: Veeck <github@veeck.de>
Co-authored-by: veeck <michael@veeck.de>
Co-authored-by: dWoolridge <dwoolridge@charter.net>
Co-authored-by: Johan <jojjepersson@yahoo.se>
Co-authored-by: Dario Mratovich <dario_mratovich@hotmail.com>
Co-authored-by: Dario Mratovich <dario.mratovich@outlook.com>
Co-authored-by: Magnus <34011212+MagMar94@users.noreply.github.com>
Co-authored-by: Naveen <172697+naveensrinivasan@users.noreply.github.com>
Co-authored-by: buxxi <buxxi@omfilm.net>
Co-authored-by: Thomas Hirschberger <47733292+Tom-Hirschberger@users.noreply.github.com>
Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
Co-authored-by: Andrés Vanegas Jiménez <142350+angeldeejay@users.noreply.github.com>
2023-01-01 18:09:08 +01:00

177 lines
4.0 KiB
JavaScript

const _ = require("lodash");
/**
* @param {object} extendedData extra data to add to the default mock data
* @returns {string} mocked current weather data
*/
const generateWeather = (extendedData = {}) => {
return JSON.stringify(
_.merge(
{},
{
coord: {
lon: 11.58,
lat: 48.14
},
weather: [
{
id: 615,
main: "Snow",
description: "light rain and snow",
icon: "13d"
},
{
id: 500,
main: "Rain",
description: "light rain",
icon: "10d"
}
],
base: "stations",
main: {
temp: 1.49,
pressure: 1005,
humidity: 93.7,
temp_min: 1,
temp_max: 2
},
visibility: 7000,
wind: {
speed: 11.8,
deg: 250
},
clouds: {
all: 75
},
dt: 1547387400,
sys: {
type: 1,
id: 1267,
message: 0.0031,
country: "DE",
sunrise: 1547362817,
sunset: 1547394301
},
id: 2867714,
name: "Munich",
cod: 200
},
extendedData
)
);
};
/**
* @param {object} extendedData extra data to add to the default mock data
* @returns {string} mocked forecast weather data
*/
const generateWeatherForecast = (extendedData = {}) => {
return JSON.stringify(
_.merge(
{},
{
city: {
id: 2867714,
name: "Munich",
coord: { lon: 11.5754, lat: 48.1371 },
country: "DE",
population: 1260391,
timezone: 7200
},
cod: "200",
message: 0.9653487,
cnt: 7,
list: [
{
dt: 1568372400,
sunrise: 1568350044,
sunset: 1568395948,
temp: { day: 24.44, min: 15.35, max: 24.44, night: 15.35, eve: 18, morn: 23.03 },
pressure: 1031.65,
humidity: 70,
weather: [{ id: 801, main: "Clouds", description: "few clouds", icon: "02d" }],
speed: 3.35,
deg: 314,
clouds: 21
},
{
dt: 1568458800,
sunrise: 1568436525,
sunset: 1568482223,
temp: { day: 20.81, min: 13.56, max: 21.02, night: 13.56, eve: 16.6, morn: 15.88 },
pressure: 1028.81,
humidity: 72,
weather: [{ id: 500, main: "Rain", description: "light rain", icon: "10d" }],
speed: 2.21,
deg: 81,
clouds: 100
},
{
dt: 1568545200,
sunrise: 1568523007,
sunset: 1568568497,
temp: { day: 22.65, min: 13.76, max: 22.88, night: 15.27, eve: 17.45, morn: 13.76 },
pressure: 1023.75,
humidity: 64,
weather: [{ id: 800, main: "Clear", description: "sky is clear", icon: "01d" }],
speed: 1.15,
deg: 7,
clouds: 0
},
{
dt: 1568631600,
sunrise: 1568609489,
sunset: 1568654771,
temp: { day: 23.45, min: 13.95, max: 23.45, night: 13.95, eve: 17.75, morn: 15.21 },
pressure: 1020.41,
humidity: 64,
weather: [{ id: 800, main: "Clear", description: "sky is clear", icon: "01d" }],
speed: 3.07,
deg: 298,
clouds: 7
},
{
dt: 1568718000,
sunrise: 1568695970,
sunset: 1568741045,
temp: { day: 20.55, min: 10.95, max: 20.55, night: 10.95, eve: 14.82, morn: 13.24 },
pressure: 1019.4,
humidity: 66,
weather: [{ id: 800, main: "Clear", description: "sky is clear", icon: "01d" }],
speed: 2.8,
deg: 333,
clouds: 2
},
{
dt: 1568804400,
sunrise: 1568782452,
sunset: 1568827319,
temp: { day: 18.15, min: 7.75, max: 18.15, night: 7.75, eve: 12.45, morn: 9.41 },
pressure: 1017.56,
humidity: 52,
weather: [{ id: 800, main: "Clear", description: "sky is clear", icon: "01d" }],
speed: 2.92,
deg: 34,
clouds: 0
},
{
dt: 1568890800,
sunrise: 1568868934,
sunset: 1568913593,
temp: { day: 14.85, min: 5.56, max: 15.05, night: 5.56, eve: 9.56, morn: 6.25 },
pressure: 1022.7,
humidity: 59,
weather: [{ id: 800, main: "Clear", description: "sky is clear", icon: "01d" }],
speed: 2.89,
deg: 51,
clouds: 1
}
]
},
extendedData
)
);
};
module.exports = { generateWeather, generateWeatherForecast };