100 Commits

Author SHA1 Message Date
Kristjan ESPERANTO
3124b0a9c5
Replace … with (#2973)
I think it is clearer if we don't use the HTML entity.

Co-authored-by: Karsten Hassel <hassel@gmx.de>
2022-12-10 21:50:56 +01:00
Magnus
bd0b3c00ad
New weather provider: Yr.no (#2948)
# Added Yr.no as a weather provider

Yr.no is a free Norwegian weather service. The configuration is quite
simple:
```js
{
    weatherProvider: "yr",
    lat: 59.9171,
    lon: 10.7276,
    altitude: 30
}
```
The latitude and longitude cannot have more than 4 decimals, but that
should be plenty. To quote yr: "There is no need to ask for weather
forecasts with nanometer precision!". The altitude should be meters
above sea level and defaults to 0. If `type` is set to `current` the
symbol can display the next 1, 6 or 12 hours by setting
`currentForecastHours` (default is 1).

It states in [Getting
started-guide](https://developer.yr.no/doc/GettingStarted/) that users
of the API should cache the results and use the `Expires`-header to know
when to ask for new data. By using the `If-Modified-Since`-header we can
avoid downloading the same data over and over again. I chose not to
override the `User-Agent`-header set in
[`server.js`](https://github.com/MichMich/MagicMirror/blob/a328ce5/js/server.js#L97)
even though it does not comply with [the terms of
service](https://developer.yr.no/doc/TermsOfService/). It currently
works with the default header, and by searching the web for MagicMirror
the GitHub-repo should be easy to find without an explicit link.

I also had to make some minor changes to `server.js` and
`weatherprovider.js` to be able to send and return HTTP headers. To
handle the HTTP 304 response without body I chose to return `undefined`
so we easily can use the response as a condition: `if (response) ...`.

The documentation for the API is available here:
- [API Reference overview](https://api.met.no/weatherapi/)
-
[Locationforecast](https://api.met.no/weatherapi/locationforecast/2.0/)
- Used to get the weather forecast
- [Sunrise](https://api.met.no/weatherapi/sunrise/2.0/documentation) -
used to find sunrise and sunset times

Co-authored-by: Veeck <github@veeck.de>
2022-11-08 06:18:47 +01:00
Magnus
4d47c0837f
Support HTTP headers with CORS-method (#2957)
Adds support for sending and receiving HTTP-headers when using the
CORS-method.

This change is required for the Yr weather-provider introduced in
https://github.com/MichMich/MagicMirror/pull/2948.

To make it easier to add unit tests I moved the server-functions into a
separate file.
2022-10-30 18:14:02 +01:00
Veeck
f79d3f007d
Cleanup jest config (#2959)
Some small cleanups with regards to jest
- call jest directly (nyc is integrated in jest these days)
- move jest config into seperate file so we dont clutter up the
package.json
- remove empty test file for newsletter-unit-tests
- update dependencies that touch jest
- try out v8 as coverageProvider

Co-authored-by: veeck <michael@veeck.de>
2022-10-28 20:57:08 +02:00
Veeck
c191ff0032
Refactor common weather methods into utils class (#2958)
Co-authored-by: veeck <michael@veeck.de>
2022-10-28 19:56:55 +02:00
Veeck
2d3940a4ff
Use metric units internally in all weatherproviders (#2849)
So finally I think this refactorin is ready to be reviewed :-)

DONE:
- [x] Removed all conversion functions for wind and temperature from
specific weatherproviders
- [x] Use internally only metric units: celsius for temperature, meters
per seconds for wind
- [x] Convert temp and wind into the configured units when displaying
data on the UI
- [x] look how beaufort calculation uses metrics, added knots as new
windunit
- [x] add more e2e tests 

Checked providers:
- [x] Darksky
- [x] EnvCanada
- [x] OpenWeatherMap
- [x] SMHI provider 
- [x] UK Met Office
- [x] UK Met Office DataHub
- [x] WeatherBit
- [x] WeatherFlow
- [x] WeatherGov

TODO in different tickets:
- check weatherproviders for usage of weatherEndpoint (as seen in
https://github.com/MichMich/MagicMirror-Documentation/issues/131) -> see
#2926
- cleanup precipations -> #2953

Co-authored-by: veeck <michael@veeck.de>
2022-10-24 19:41:34 +02:00
Veeck
a328ce537f
Cleanup test directory (#2937)
Moves files around and renames some so that the structure is cleaner and
more consistent
2022-10-07 12:16:37 -05:00
Karsten Hassel
f04d578704
improve tests (#2923)
use es6 syntax in all tests, split weather tests, remove callbacks
2022-10-04 10:15:24 +02:00
Karsten Hassel
4cc3e481cc update dependencies, revert electron to v19 2022-09-05 23:26:04 +02:00
Karsten Hassel
eb32ec89b4 remove old weather modules 2022-01-08 23:08:41 +01:00
Felix Wiedenbach
1751cabb9d remove obsolete snapshot 2021-10-02 14:56:13 +02:00
Felix Wiedenbach
b094707324 remove mocking from implementation and use jest to mock git cli instead 2021-10-02 14:08:16 +02:00
Karsten Hassel
277055f44e added tests for updatenotification 2021-09-10 21:12:27 +02:00
Karsten Hassel
eb63745664 update tests in updatenotification_spec.js due to problems after merging PR's 2021-09-09 21:29:28 +02:00
Karsten Hassel
91d72e48ad Merge branch 'develop' into logger 2021-09-09 21:18:28 +02:00
Karsten Hassel
d12a587f11 Merge branch 'updatenotification' into logger 2021-09-09 20:51:58 +02:00
Karsten Hassel
2b147bb98b do logger mocking in logger.js, remove sandbox stuff from unit tests 2021-09-09 20:50:35 +02:00
Michael Teeuw
6529eaaf9a
Merge pull request #2650 from rejas/weather 2021-09-09 20:30:37 +02:00
Karsten Hassel
690efc0aff fix test 2021-09-09 00:48:39 +02:00
Karsten Hassel
dd43f35bbe add unit tests 2021-09-09 00:03:28 +02:00
rejas
087a472765 Fix tomezone test error as reported by @khassel 2021-09-06 21:15:23 +02:00
rejas
f2bc10c5c0 Add tests for new methods 2021-08-31 23:32:05 +02:00
rejas
f84f590f1d Start filling last gaps of jsdoc 2021-08-03 08:25:57 +02:00
rejas
53720ae8ae Fix some eslint issues in the tests 2021-07-14 10:41:29 +02:00
veeck
39aa2dfe01 Run linter over all files again 2021-07-14 10:41:29 +02:00
karsten13
ebb5dee1fc run prettier 2021-06-17 23:19:57 +02:00
Karsten Hassel
d9edaffd9c reset changes on js/logger.js, mock logger.js in global_vars tests, workaround for failing dev_console test 2021-06-17 22:50:26 +02:00
Karsten Hassel
2af4009a93 change missing translations log, disable console.log in unit tests 2021-06-12 22:26:02 +02:00
Karsten Hassel
a5f7c946cc jest setup changes, increase setMaxListeners, disable console.log in tests/unit/global_vars 2021-06-12 21:26:08 +02:00
karsten13
1a244726aa run prettier 2021-06-11 22:24:21 +02:00
Karsten Hassel
044935a164 add jest options 2021-06-11 22:18:05 +02:00
Karsten Hassel
0e14d3d6e8 snapshot e2e 2021-06-09 00:19:43 +02:00
Karsten Hassel
16bbb42b8d remove chai from unit tests 2021-06-08 00:47:15 +02:00
Karsten Hassel
66759a33fa unit tests 2021-06-07 00:16:53 +02:00
rejas
fb8bd657de Move weatherforecast mock data in better suited directory 2021-04-27 13:14:07 +02:00
rejas
d736dd92be Use es6 notation in tests 2021-04-18 14:51:28 +02:00
rejas
5e6cbeb9ba Convert some code to es6 2021-03-14 10:40:14 +01:00
Ashish Tank
4966d6c920 Fixed Unit test case error for #2221 2021-01-14 19:10:04 +01:00
Ashish Tank
2c3e8533c7 Issue #2221 - Weather forecast always shows night icons in day time 2021-01-10 16:24:46 +01:00
Felix Wiedenbach
a9a70fd2e9 linting and fix defualt module test 2021-01-05 20:04:02 +01:00
Jake Mulley
a6386bd60e
Update npm packages and resolve package changes 2020-11-08 21:18:19 +00:00
rejas
8fa858ca8c Cleanup test descriptions 2020-07-18 22:16:44 +02:00
Michael Teeuw
29ed63286c
Merge pull request #2089 from rejas/newsfeed
Cleaned up newsfeed module code
2020-07-17 16:28:44 +02:00
rejas
b9ccb7a892 Add new test to see if coverage improves
it does :-)

  calendar.js                       |    8.97 |     9.57 |   11.54 |     8.7 | 63-413,446-659,690-693,699,733-771

->

  calendar.js                       |    9.97 |    10.64 |   11.54 |     9.7 | 63-413,446-659,699,733-771
2020-07-15 13:15:03 +02:00
rejas
8dc88fe64b Remove unused helper function and its unit test 2020-07-12 10:32:16 +02:00
rejas
2d7c5a827f Cleanup test expectation 2020-07-09 20:44:52 +02:00
Veeck
85c32ef843 Use const in test requires 2020-07-09 20:30:43 +02:00
rejas
dc089d7db9 Remove stripCommentsFromJson code and test
Since we dont allow comments in the json anymore anyway
2020-07-09 20:30:26 +02:00
Veeck
abb5dc5739 Run prettier over ALL files once
No other changes done in this commit
2020-05-11 22:22:32 +02:00
Veeck
c8a0f1d0de Fix some more undefs that popped up out of nowhere 2020-05-05 14:54:49 +02:00