Skip to content

Commit 38febc8

Browse files
author
nkl-kst
authored
Merge pull request #9 from nkl-kst/dev
Version 1.1.1
2 parents 9865f38 + ccb4dad commit 38febc8

6 files changed

+67
-11
lines changed

.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"IconMapper": true,
1010
"Module": true,
1111
"moment": true,
12-
"Log": true
12+
"Log": true,
13+
"version": true
1314
},
1415
"rules": {
1516
"indent": ["error", 4],

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
---
77

8+
## [1.1.1] - 2018-10-31
9+
10+
### Added
11+
- Icon mapping for thunder and additional rain types
12+
13+
### Updated
14+
- eslint-plugin-node@^8.0.0
15+
- jsdom@^13.0.0
16+
- Use Font Awesome 5 icons if MagicMirror version is higher than 2.5.0
17+
18+
819
## [1.1.0] - 2018-10-26
920

1021
- New minor version with new features (e.g. animated icons), bugfixes etc.

IconMapper.js

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ IconMapper = {
3333
'122000': 'rainy-3',
3434
'122200': 'snowy-3',
3535
'123000': 'rainy-1',
36+
'123001': 'thunder',
37+
'123002': 'rainy-1',
3638
'123300': 'snowy-2',
3739
'200000': 'night',
3840
'210000': 'cloudy-night-1',
@@ -51,6 +53,8 @@ IconMapper = {
5153
'222000': 'rainy-6',
5254
'222200': 'rainy-7',
5355
'223000': 'rainy-5',
56+
'223001': 'thunder',
57+
'223002': 'rainy-5',
5458
'223300': 'snowy-4',
5559
'320000': 'cloudy',
5660
'320100': 'snowy-4',
@@ -61,6 +65,8 @@ IconMapper = {
6165
'322000': 'rainy-6',
6266
'322200': 'rainy-7',
6367
'323000': 'rainy-5',
68+
'323001': 'thunder',
69+
'323002': 'rainy-5',
6470
'323300': 'snowy-4',
6571
'330000': 'cloudy',
6672
'330100': 'snowy-4',

MMM-RBB-Weather.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,14 @@ Module.register('MMM-RBB-Weather', {
201201
if (temp >= 24) return 'fa-thermometer-three-quarters';
202202
if (temp >= 16) return 'fa-thermometer-half';
203203
if (temp >= 8) return 'fa-thermometer-quarter';
204-
if (temp >= 0) return 'fa-thermometer-empty'; // TODO: Use "fa-snowflake" when Font Awesome 5 is available
205-
return 'fa-asterisk';
204+
if (temp >= 0) return 'fa-thermometer-empty';
205+
206+
// Font Awesome 5 (with fa-snowflake) is not available in MagicMirror <= 2.5.0
207+
if (version.localeCompare('2.5.0', 'en', { numeric: true }) <= 0) {
208+
return 'fa-asterisk';
209+
}
210+
211+
return 'fa-snowflake';
206212
},
207213

208214
/**
@@ -216,8 +222,13 @@ Module.register('MMM-RBB-Weather', {
216222
getRainProbabilityIcon: function(prob) {
217223

218224
if (prob <= 15) {
219-
// TODO: Use "fa-tint-slash" when Font Awesome 5 is available
220-
return 'fa-tint dimmed';
225+
226+
// Font Awesome 5 (with fa-tint-slash) is not available in MagicMirror <= 2.5.0
227+
if (version.localeCompare('2.5.0', 'en', { numeric: true }) <= 0) {
228+
return 'fa-tint dimmed';
229+
}
230+
231+
return 'fa-tint-slash';
221232
}
222233

223234
if (prob >= 70) {

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "MMM-RBB-Weather",
3-
"version": "1.0.0",
3+
"version": "1.1.1",
44
"description": "MagicMirror module to display RBB weather data.",
55
"author": "Nikolai Keist",
66
"license": "MIT",
@@ -24,10 +24,10 @@
2424
"eslint": "^5.7.0",
2525
"eslint-config-standard": "^12.0.0",
2626
"eslint-plugin-import": "^2.14.0",
27-
"eslint-plugin-node": "^7.0.1",
27+
"eslint-plugin-node": "^8.0.0",
2828
"eslint-plugin-promise": "^4.0.1",
2929
"eslint-plugin-standard": "^4.0.0",
30-
"jsdom": "^12.2.0",
30+
"jsdom": "^13.0.0",
3131
"libxmljs": "^0.19.5",
3232
"mocha": "^5.2.0",
3333
"moment": "^2.22.2",

test/unit/MMM-RBB-Weather-Test.js

+30-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ describe('MMM-RBB-Weather', () => {
4444

4545
// Fake DOM
4646
document = new JSDOM(`<!DOCTYPE html>`).window.document;
47+
48+
// Fake MagicMirror Version
49+
version = '2.6.0';
4750
});
4851

4952
afterEach(() => {
@@ -76,7 +79,7 @@ describe('MMM-RBB-Weather', () => {
7679

7780
describe('getTranslations', () => {
7881

79-
it('should return an array', () => {
82+
it('should return an object', () => {
8083

8184
// Act
8285
let translations = module.getTranslations();
@@ -339,7 +342,19 @@ describe('MMM-RBB-Weather', () => {
339342
assert.deepStrictEqual(icon, 'fa-thermometer-empty');
340343
});
341344

342-
it('should return "fa-asterisk" icon if temperature is lower than 0', () => {
345+
it('should return "fa-snowflake" icon if temperature is lower than 0', () => {
346+
347+
// Act
348+
let icon = module.getTempIcon(-1);
349+
350+
// Assert
351+
assert.deepStrictEqual(icon, 'fa-snowflake');
352+
});
353+
354+
it('should return "fa-asterisk" icon if temperature is lower than 0 and version is lower or equal 2.5.0', () => {
355+
356+
// Arrange
357+
version = '2.5.0';
343358

344359
// Act
345360
let icon = module.getTempIcon(-1);
@@ -360,7 +375,19 @@ describe('MMM-RBB-Weather', () => {
360375
assert.deepStrictEqual(icon, 'fa-tint');
361376
});
362377

363-
it('should return "fa-tint dimmed" icon if probability is under or equal low', () => {
378+
it('should return "fa-tint-slash" icon if probability is under or equal low', () => {
379+
380+
// Act
381+
let icon = module.getRainProbabilityIcon(15);
382+
383+
// Assert
384+
assert.deepStrictEqual(icon, 'fa-tint-slash');
385+
});
386+
387+
it('should return "fa-tint dimmed" icon if probability is under or equal low and version is lower or equal 2.5.0', () => {
388+
389+
// Arrange
390+
version = '2.5.0';
364391

365392
// Act
366393
let icon = module.getRainProbabilityIcon(15);

0 commit comments

Comments
 (0)