Run prettier over ALL files once

No other changes done in this commit
This commit is contained in:
Veeck
2020-05-11 22:22:32 +02:00
parent 3a5a29efc0
commit abb5dc5739
160 changed files with 2369 additions and 2210 deletions

View File

@@ -6,96 +6,96 @@ const it = global.it;
const beforeEach = global.beforeEach;
const afterEach = global.afterEach;
describe("Calendar module", function() {
describe("Calendar module", function () {
helpers.setupTimeout(this);
var app = null;
beforeEach(function() {
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function(startedApp) {
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function() {
afterEach(function () {
return helpers.stopApplication(app);
});
describe("Default configuration", function() {
before(function() {
describe("Default configuration", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/default.js";
});
it("Should return TestEvents", function() {
it("Should return TestEvents", function () {
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
});
});
describe("Basic auth", function() {
before(function() {
describe("Basic auth", function () {
before(function () {
serverBasicAuth.listen(8010);
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/basic-auth.js";
});
after(function(done) {
after(function (done) {
serverBasicAuth.close(done());
});
it("Should return TestEvents", function() {
it("Should return TestEvents", function () {
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
});
});
describe("Basic auth by default", function() {
before(function() {
describe("Basic auth by default", function () {
before(function () {
serverBasicAuth.listen(8011);
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/auth-default.js";
});
after(function(done) {
after(function (done) {
serverBasicAuth.close(done());
});
it("Should return TestEvents", function() {
it("Should return TestEvents", function () {
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
});
});
describe("Basic auth backward compatibility configuration: DEPRECATED", function() {
before(function() {
describe("Basic auth backward compatibility configuration: DEPRECATED", function () {
before(function () {
serverBasicAuth.listen(8012);
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/old-basic-auth.js";
});
after(function(done) {
after(function (done) {
serverBasicAuth.close(done());
});
it("Should return TestEvents", function() {
it("Should return TestEvents", function () {
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
});
});
describe("Fail Basic auth", function() {
before(function() {
describe("Fail Basic auth", function () {
before(function () {
serverBasicAuth.listen(8020);
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/fail-basic-auth.js";
});
after(function(done) {
after(function (done) {
serverBasicAuth.close(done());
});
it("Should return No upcoming events", function() {
it("Should return No upcoming events", function () {
return app.client.waitUntilTextExists(".calendar", "No upcoming events.", 10000);
});
});

View File

@@ -5,81 +5,80 @@ const it = global.it;
const beforeEach = global.beforeEach;
const afterEach = global.afterEach;
describe("Clock set to spanish language module", function() {
describe("Clock set to spanish language module", function () {
helpers.setupTimeout(this);
var app = null;
beforeEach(function() {
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function(startedApp) {
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function() {
afterEach(function () {
return helpers.stopApplication(app);
});
describe("with default 24hr clock config", function() {
before(function() {
describe("with default 24hr clock config", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_24hr.js";
});
it("shows date with correct format", function() {
it("shows date with correct format", function () {
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
return app.client.waitUntilWindowLoaded().getText(".clock .date").should.eventually.match(dateRegex);
});
it("shows time in 24hr format", function() {
it("shows time in 24hr format", function () {
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
});
});
describe("with default 12hr clock config", function() {
before(function() {
describe("with default 12hr clock config", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_12hr.js";
});
it("shows date with correct format", function() {
it("shows date with correct format", function () {
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
return app.client.waitUntilWindowLoaded().getText(".clock .date").should.eventually.match(dateRegex);
});
it("shows time in 12hr format", function() {
it("shows time in 12hr format", function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
});
});
describe("with showPeriodUpper config enabled", function() {
before(function() {
describe("with showPeriodUpper config enabled", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_showPeriodUpper.js";
});
it("shows 12hr time with upper case AM/PM", function() {
it("shows 12hr time with upper case AM/PM", function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
});
});
describe("with showWeek config enabled", function() {
before(function() {
describe("with showWeek config enabled", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_showWeek.js";
});
it("shows week with correct format", function() {
it("shows week with correct format", function () {
const weekRegex = /^Semana [0-9]{1,2}$/;
return app.client.waitUntilWindowLoaded()
.getText(".clock .week").should.eventually.match(weekRegex);
return app.client.waitUntilWindowLoaded().getText(".clock .week").should.eventually.match(weekRegex);
});
});
});

View File

@@ -5,95 +5,95 @@ const it = global.it;
const beforeEach = global.beforeEach;
const afterEach = global.afterEach;
describe("Clock module", function() {
describe("Clock module", function () {
helpers.setupTimeout(this);
var app = null;
beforeEach(function() {
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function(startedApp) {
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function() {
afterEach(function () {
return helpers.stopApplication(app);
});
describe("with default 24hr clock config", function() {
before(function() {
describe("with default 24hr clock config", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_24hr.js";
});
it("shows date with correct format", function() {
it("shows date with correct format", function () {
const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
return app.client.waitUntilWindowLoaded().getText(".clock .date").should.eventually.match(dateRegex);
});
it("shows time in 24hr format", function() {
it("shows time in 24hr format", function () {
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
});
});
describe("with default 12hr clock config", function() {
before(function() {
describe("with default 12hr clock config", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_12hr.js";
});
it("shows date with correct format", function() {
it("shows date with correct format", function () {
const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
return app.client.waitUntilWindowLoaded().getText(".clock .date").should.eventually.match(dateRegex);
});
it("shows time in 12hr format", function() {
it("shows time in 12hr format", function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
});
});
describe("with showPeriodUpper config enabled", function() {
before(function() {
describe("with showPeriodUpper config enabled", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showPeriodUpper.js";
});
it("shows 12hr time with upper case AM/PM", function() {
it("shows 12hr time with upper case AM/PM", function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
});
});
describe("with displaySeconds config disabled", function() {
before(function() {
describe("with displaySeconds config disabled", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_displaySeconds_false.js";
});
it("shows 12hr time without seconds am/pm", function() {
it("shows 12hr time without seconds am/pm", function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
});
});
describe("with showWeek config enabled", function() {
before(function() {
describe("with showWeek config enabled", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showWeek.js";
});
it("shows week with correct format", function() {
it("shows week with correct format", function () {
const weekRegex = /^Week [0-9]{1,2}$/;
return app.client.waitUntilWindowLoaded().getText(".clock .week").should.eventually.match(weekRegex);
});
it("shows week with correct number of week of year", function() {
it("shows week with correct number of week of year", function () {
it("FIXME: if the day is a sunday this not match");
// const currentWeekNumber = require("current-week-number")();
// const weekToShow = "Week " + currentWeekNumber;

View File

@@ -6,101 +6,119 @@ const it = global.it;
const beforeEach = global.beforeEach;
const afterEach = global.afterEach;
describe("Compliments module", function() {
describe("Compliments module", function () {
helpers.setupTimeout(this);
var app = null;
beforeEach(function() {
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function(startedApp) {
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function() {
afterEach(function () {
return helpers.stopApplication(app);
});
describe("parts of days", function() {
before(function() {
describe("parts of days", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_parts_day.js";
});
it("if Morning compliments for that part of day", function() {
it("if Morning compliments for that part of day", function () {
var hour = new Date().getHours();
if (hour >= 3 && hour < 12) {
// if morning check
return app.client.waitUntilWindowLoaded().getText(".compliments").then(function(text) {
expect(text).to.be.oneOf(["Hi", "Good Morning", "Morning test"]);
});
return app.client
.waitUntilWindowLoaded()
.getText(".compliments")
.then(function (text) {
expect(text).to.be.oneOf(["Hi", "Good Morning", "Morning test"]);
});
}
});
it("if Afternoon show Compliments for that part of day", function() {
it("if Afternoon show Compliments for that part of day", function () {
var hour = new Date().getHours();
if (hour >= 12 && hour < 17) {
// if morning check
return app.client.waitUntilWindowLoaded().getText(".compliments").then(function(text) {
expect(text).to.be.oneOf(["Hello", "Good Afternoon", "Afternoon test"]);
});
return app.client
.waitUntilWindowLoaded()
.getText(".compliments")
.then(function (text) {
expect(text).to.be.oneOf(["Hello", "Good Afternoon", "Afternoon test"]);
});
}
});
it("if Evening show Compliments for that part of day", function() {
it("if Evening show Compliments for that part of day", function () {
var hour = new Date().getHours();
if (!(hour >= 3 && hour < 12) && !(hour >= 12 && hour < 17)) {
// if evening check
return app.client.waitUntilWindowLoaded().getText(".compliments").then(function(text) {
expect(text).to.be.oneOf(["Hello There", "Good Evening", "Evening test"]);
});
return app.client
.waitUntilWindowLoaded()
.getText(".compliments")
.then(function (text) {
expect(text).to.be.oneOf(["Hello There", "Good Evening", "Evening test"]);
});
}
});
});
describe("Feature anytime in compliments module", function() {
describe("Set anytime and empty compliments for morning, evening and afternoon ", function() {
before(function() {
describe("Feature anytime in compliments module", function () {
describe("Set anytime and empty compliments for morning, evening and afternoon ", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_anytime.js";
});
it("Show anytime because if configure empty parts of day compliments and set anytime compliments", function() {
return app.client.waitUntilWindowLoaded().getText(".compliments").then(function(text) {
expect(text).to.be.oneOf(["Anytime here"]);
});
it("Show anytime because if configure empty parts of day compliments and set anytime compliments", function () {
return app.client
.waitUntilWindowLoaded()
.getText(".compliments")
.then(function (text) {
expect(text).to.be.oneOf(["Anytime here"]);
});
});
});
describe("Only anytime present in configuration compliments", function() {
before(function() {
describe("Only anytime present in configuration compliments", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_only_anytime.js";
});
it("Show anytime compliments", function() {
return app.client.waitUntilWindowLoaded().getText(".compliments").then(function(text) {
expect(text).to.be.oneOf(["Anytime here"]);
});
it("Show anytime compliments", function () {
return app.client
.waitUntilWindowLoaded()
.getText(".compliments")
.then(function (text) {
expect(text).to.be.oneOf(["Anytime here"]);
});
});
});
});
describe("Feature date in compliments module", function() {
describe("Set date and empty compliments for anytime, morning, evening and afternoon", function() {
before(function() {
describe("Feature date in compliments module", function () {
describe("Set date and empty compliments for anytime, morning, evening and afternoon", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_date.js";
});
it("Show happy new year compliment on new years day", function() {
return app.client.waitUntilWindowLoaded().getText(".compliments").then(function(text) {
expect(text).to.be.oneOf(["Happy new year!"]);
});
it("Show happy new year compliment on new years day", function () {
return app.client
.waitUntilWindowLoaded()
.getText(".compliments")
.then(function (text) {
expect(text).to.be.oneOf(["Happy new year!"]);
});
});
});
});

View File

@@ -5,46 +5,44 @@ const it = global.it;
const beforeEach = global.beforeEach;
const afterEach = global.afterEach;
describe("Test helloworld module", function() {
describe("Test helloworld module", function () {
helpers.setupTimeout(this);
var app = null;
beforeEach(function() {
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function(startedApp) {
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function() {
afterEach(function () {
return helpers.stopApplication(app);
});
describe("helloworld set config text", function () {
before(function() {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/helloworld/helloworld.js";
});
it("Test message helloworld module", function () {
return app.client.waitUntilWindowLoaded()
.getText(".helloworld").should.eventually.equal("Test HelloWorld Module");
return app.client.waitUntilWindowLoaded().getText(".helloworld").should.eventually.equal("Test HelloWorld Module");
});
});
describe("helloworld default config text", function () {
before(function() {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/helloworld/helloworld_default.js";
});
it("Test message helloworld module", function () {
return app.client.waitUntilWindowLoaded()
.getText(".helloworld").should.eventually.equal("Hello World!");
return app.client.waitUntilWindowLoaded().getText(".helloworld").should.eventually.equal("Hello World!");
});
});
});

View File

@@ -1,4 +1,4 @@
const generateWeather = require("./weather_current");
const generateWeatherForecast = require("./weather_forecast");
module.exports = {generateWeather, generateWeatherForecast};
module.exports = { generateWeather, generateWeatherForecast };

View File

@@ -1,54 +1,60 @@
const _ = require("lodash");
function generateWeather(extendedData = {}) {
return JSON.stringify(_.merge({}, {
coord:{
lon: 11.58,
lat: 48.14
},
weather:[
return JSON.stringify(
_.merge(
{},
{
id: 615,
main: "Snow",
description: "light rain and snow",
icon: "13d"
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
},
{
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));
extendedData
)
);
}
module.exports = generateWeather;

View File

@@ -1,97 +1,111 @@
const _ = require("lodash");
function 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));
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 = generateWeatherForecast;

View File

@@ -5,31 +5,31 @@ const it = global.it;
const beforeEach = global.beforeEach;
const afterEach = global.afterEach;
describe("Newsfeed module", function() {
describe("Newsfeed module", function () {
helpers.setupTimeout(this);
var app = null;
beforeEach(function() {
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function(startedApp) {
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function() {
afterEach(function () {
return helpers.stopApplication(app);
});
describe("Default configuration", function() {
before(function() {
describe("Default configuration", function () {
before(function () {
process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/default.js";
});
it("show title newsfeed", function() {
it("show title newsfeed", function () {
return app.client.waitUntilTextExists(".newsfeed .small", "Rodrigo Ramirez Blog", 10000).should.be.fulfilled;
});
});

View File

@@ -6,10 +6,9 @@ const wdajaxstub = require("webdriverajaxstub");
const helpers = require("../global-setup");
const {generateWeather, generateWeatherForecast} = require("./mocks");
describe("Weather module", function() {
const { generateWeather, generateWeatherForecast } = require("./mocks");
describe("Weather module", function () {
let app;
helpers.setupTimeout(this);
@@ -24,85 +23,85 @@ describe("Weather module", function() {
app.client.setupStub();
}
afterEach(function() {
afterEach(function () {
return helpers.stopApplication(app);
});
describe("Current weather", function() {
describe("Current weather", function () {
let template;
before(function() {
before(function () {
template = fs.readFileSync(path.join(__dirname, "..", "..", "..", "modules", "default", "weather", "current.njk"), "utf8");
});
describe("Default configuration", function() {
before(function() {
describe("Default configuration", function () {
before(function () {
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/currentweather_default.js";
});
it("should render wind speed and wind direction", async function() {
it("should render wind speed and wind direction", async function () {
const weather = generateWeather();
await setup({template, data: weather});
await setup({ template, data: weather });
return app.client.waitUntilTextExists(".weather .normal.medium span:nth-child(2)", "6 WSW", 10000);
});
it("should render sunrise", async function() {
it("should render sunrise", async function () {
const sunrise = moment().startOf("day").unix();
const sunset = moment().startOf("day").unix();
const weather = generateWeather({sys: {sunrise, sunset}});
await setup({template, data: weather});
const weather = generateWeather({ sys: { sunrise, sunset } });
await setup({ template, data: weather });
await app.client.waitForExist(".weather .normal.medium span.wi.dimmed.wi-sunrise", 10000);
return app.client.waitUntilTextExists(".weather .normal.medium span:nth-child(4)", "12:00 am", 10000);
});
it("should render sunset", async function() {
it("should render sunset", async function () {
const sunrise = moment().startOf("day").unix();
const sunset = moment().endOf("day").unix();
const weather = generateWeather({sys: {sunrise, sunset}});
await setup({template, data: weather});
const weather = generateWeather({ sys: { sunrise, sunset } });
await setup({ template, data: weather });
await app.client.waitForExist(".weather .normal.medium span.wi.dimmed.wi-sunset", 10000);
return app.client.waitUntilTextExists(".weather .normal.medium span:nth-child(4)", "11:59 pm", 10000);
});
it("should render temperature with icon", async function() {
it("should render temperature with icon", async function () {
const weather = generateWeather();
await setup({template, data: weather});
await setup({ template, data: weather });
await app.client.waitForExist(".weather .large.light span.wi.weathericon.wi-snow", 10000);
return app.client.waitUntilTextExists(".weather .large.light span.bright", "1.5°", 10000);
});
it("should render feels like temperature", async function() {
it("should render feels like temperature", async function () {
const weather = generateWeather();
await setup({template, data: weather});
await setup({ template, data: weather });
return app.client.waitUntilTextExists(".weather .normal.medium span.dimmed", "Feels like -5.6°", 10000);
});
});
describe("Configuration Options", function() {
before(function() {
describe("Configuration Options", function () {
before(function () {
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/currentweather_options.js";
});
it("should render useBeaufort = false", async function() {
it("should render useBeaufort = false", async function () {
const weather = generateWeather();
await setup({template, data: weather});
await setup({ template, data: weather });
return app.client.waitUntilTextExists(".weather .normal.medium span:nth-child(2)", "12", 10000);
});
it("should render showWindDirectionAsArrow = true", async function() {
it("should render showWindDirectionAsArrow = true", async function () {
const weather = generateWeather();
await setup({template, data: weather});
await setup({ template, data: weather });
await app.client.waitForExist(".weather .normal.medium sup i.fa-long-arrow-up", 10000);
const element = await app.client.getHTML(".weather .normal.medium sup i.fa-long-arrow-up");
@@ -110,17 +109,17 @@ describe("Weather module", function() {
expect(element).to.include("transform:rotate(250deg);");
});
it("should render showHumidity = true", async function() {
it("should render showHumidity = true", async function () {
const weather = generateWeather();
await setup({template, data: weather});
await setup({ template, data: weather });
await app.client.waitUntilTextExists(".weather .normal.medium span:nth-child(3)", "93", 10000);
return app.client.waitForExist(".weather .normal.medium sup i.wi-humidity", 10000);
});
it("should render degreeLabel = true", async function() {
it("should render degreeLabel = true", async function () {
const weather = generateWeather();
await setup({template, data: weather});
await setup({ template, data: weather });
await app.client.waitUntilTextExists(".weather .large.light span.bright", "1°C", 10000);
@@ -128,41 +127,41 @@ describe("Weather module", function() {
});
});
describe("Current weather units", function() {
before(function() {
describe("Current weather units", function () {
before(function () {
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/currentweather_units.js";
});
it("should render imperial units", async function() {
it("should render imperial units", async function () {
const weather = generateWeather({
main:{
temp: 1.49 * 9 / 5 + 32,
temp_min: 1 * 9 / 5 + 32,
temp_max: 2 * 9 / 5 + 32
main: {
temp: (1.49 * 9) / 5 + 32,
temp_min: (1 * 9) / 5 + 32,
temp_max: (2 * 9) / 5 + 32
},
wind:{
wind: {
speed: 11.8 * 2.23694
},
}
});
await setup({template, data: weather});
await setup({ template, data: weather });
await app.client.waitUntilTextExists(".weather .normal.medium span:nth-child(2)", "6 WSW", 10000);
await app.client.waitUntilTextExists(".weather .large.light span.bright", "34,7°", 10000);
return app.client.waitUntilTextExists(".weather .normal.medium span.dimmed", "22,0°", 10000);
});
it("should render decimalSymbol = ','", async function() {
it("should render decimalSymbol = ','", async function () {
const weather = generateWeather({
main:{
temp: 1.49 * 9 / 5 + 32,
temp_min: 1 * 9 / 5 + 32,
temp_max: 2 * 9 / 5 + 32
main: {
temp: (1.49 * 9) / 5 + 32,
temp_min: (1 * 9) / 5 + 32,
temp_max: (2 * 9) / 5 + 32
},
wind:{
wind: {
speed: 11.8 * 2.23694
},
}
});
await setup({template, data: weather});
await setup({ template, data: weather });
await app.client.waitUntilTextExists(".weather .normal.medium span:nth-child(3)", "93,7", 10000);
await app.client.waitUntilTextExists(".weather .large.light span.bright", "34,7°", 10000);
@@ -171,21 +170,21 @@ describe("Weather module", function() {
});
});
describe("Weather Forecast", function() {
describe("Weather Forecast", function () {
let template;
before(function() {
before(function () {
template = fs.readFileSync(path.join(__dirname, "..", "..", "..", "modules", "default", "weather", "forecast.njk"), "utf8");
});
describe("Default configuration", function() {
before(function() {
describe("Default configuration", function () {
before(function () {
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/forecastweather_default.js";
});
it("should render days", async function() {
it("should render days", async function () {
const weather = generateWeatherForecast();
await setup({template, data: weather});
await setup({ template, data: weather });
const days = ["Fri", "Sat", "Sun", "Mon", "Tue"];
@@ -194,9 +193,9 @@ describe("Weather module", function() {
}
});
it("should render icons", async function() {
it("should render icons", async function () {
const weather = generateWeatherForecast();
await setup({template, data: weather});
await setup({ template, data: weather });
const icons = ["day-cloudy", "rain", "day-sunny", "day-sunny", "day-sunny"];
@@ -205,9 +204,9 @@ describe("Weather module", function() {
}
});
it("should render max temperatures", async function() {
it("should render max temperatures", async function () {
const weather = generateWeatherForecast();
await setup({template, data: weather});
await setup({ template, data: weather });
const temperatures = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"];
@@ -216,9 +215,9 @@ describe("Weather module", function() {
}
});
it("should render min temperatures", async function() {
it("should render min temperatures", async function () {
const weather = generateWeatherForecast();
await setup({template, data: weather});
await setup({ template, data: weather });
const temperatures = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"];
@@ -227,9 +226,9 @@ describe("Weather module", function() {
}
});
it("should render fading of rows", async function() {
it("should render fading of rows", async function () {
const weather = generateWeatherForecast();
await setup({template, data: weather});
await setup({ template, data: weather });
const opacities = [1, 1, 0.8, 0.5333333333333333, 0.2666666666666667];
@@ -242,21 +241,21 @@ describe("Weather module", function() {
});
});
describe("Configuration Options", function() {
before(function() {
describe("Configuration Options", function () {
before(function () {
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/forecastweather_options.js";
});
it("should render custom table class", async function() {
it("should render custom table class", async function () {
const weather = generateWeatherForecast();
await setup({template, data: weather});
await setup({ template, data: weather });
await app.client.waitForExist(".weather table.myTableClass", 10000);
});
it("should render colored rows", async function() {
it("should render colored rows", async function () {
const weather = generateWeatherForecast();
await setup({template, data: weather});
await setup({ template, data: weather });
await app.client.waitForExist(".weather table.myTableClass", 10000);