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

@@ -4,7 +4,7 @@ const expect = require("chai").expect;
const describe = global.describe;
const it = global.it;
describe("Development console tests", function() {
describe("Development console tests", function () {
// FIXME: This tests fail and crash another tests
// Suspect problem with window focus
return false;
@@ -14,47 +14,47 @@ describe("Development console tests", function() {
var app = null;
before(function() {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
});
describe("Without 'dev' commandline argument", function() {
before(function() {
describe("Without 'dev' commandline argument", function () {
before(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function(startedApp) {
.then(function (startedApp) {
app = startedApp;
});
});
after(function() {
after(function () {
return helpers.stopApplication(app);
});
it("should not open dev console when absent", function() {
it("should not open dev console when absent", function () {
return expect(app.browserWindow.isDevToolsOpened()).to.eventually.equal(false);
});
});
describe("With 'dev' commandline argument", function() {
before(function() {
describe("With 'dev' commandline argument", function () {
before(function () {
return helpers
.startApplication({
args: ["js/electron.js", "dev"]
})
.then(function(startedApp) {
.then(function (startedApp) {
app = startedApp;
});
});
after(function() {
after(function () {
return helpers.stopApplication(app);
});
it("should open dev console when provided", function() {
it("should open dev console when provided", function () {
return expect(app.browserWindow.isDevToolsOpened()).to.eventually.equal(true);
});
});

View File

@@ -7,59 +7,61 @@ const it = global.it;
const beforeEach = global.beforeEach;
const afterEach = global.afterEach;
describe("Electron app environment", function() {
describe("Electron app environment", function () {
helpers.setupTimeout(this);
var app = null;
before(function() {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
});
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);
});
it("should open a browserwindow", function() {
return app.client
.waitUntilWindowLoaded()
// .browserWindow.focus()
.getWindowCount()
.should.eventually.equal(1)
.browserWindow.isMinimized()
.should.eventually.be.false.browserWindow.isDevToolsOpened()
.should.eventually.be.false.browserWindow.isVisible()
.should.eventually.be.true.browserWindow.isFocused()
.should.eventually.be.true.browserWindow.getBounds()
.should.eventually.have.property("width")
.and.be.above(0)
.browserWindow.getBounds()
.should.eventually.have.property("height")
.and.be.above(0)
.browserWindow.getTitle()
.should.eventually.equal("MagicMirror²");
it("should open a browserwindow", function () {
return (
app.client
.waitUntilWindowLoaded()
// .browserWindow.focus()
.getWindowCount()
.should.eventually.equal(1)
.browserWindow.isMinimized()
.should.eventually.be.false.browserWindow.isDevToolsOpened()
.should.eventually.be.false.browserWindow.isVisible()
.should.eventually.be.true.browserWindow.isFocused()
.should.eventually.be.true.browserWindow.getBounds()
.should.eventually.have.property("width")
.and.be.above(0)
.browserWindow.getBounds()
.should.eventually.have.property("height")
.and.be.above(0)
.browserWindow.getTitle()
.should.eventually.equal("MagicMirror²")
);
});
it("get request from http://localhost:8080 should return 200", function(done) {
request.get("http://localhost:8080", function(err, res, body) {
it("get request from http://localhost:8080 should return 200", function (done) {
request.get("http://localhost:8080", function (err, res, body) {
expect(res.statusCode).to.equal(200);
done();
});
});
it("get request from http://localhost:8080/nothing should return 404", function(done) {
request.get("http://localhost:8080/nothing", function(err, res, body) {
it("get request from http://localhost:8080/nothing should return 404", function (done) {
request.get("http://localhost:8080/nothing", function (err, res, body) {
expect(res.statusCode).to.equal(404);
done();
});

View File

@@ -5,7 +5,7 @@ const forEach = require("mocha-each");
const describe = global.describe;
describe("All font files from roboto.css should be downloadable", function() {
describe("All font files from roboto.css should be downloadable", function () {
helpers.setupTimeout(this);
var app;
@@ -21,7 +21,7 @@ describe("All font files from roboto.css should be downloadable", function() {
match = regex.exec(fileContent);
}
before(function() {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/without_modules.js";
@@ -29,18 +29,18 @@ describe("All font files from roboto.css should be downloadable", function() {
.startApplication({
args: ["js/electron.js"]
})
.then(function(startedApp) {
.then(function (startedApp) {
app = startedApp;
});
});
after(function() {
after(function () {
return helpers.stopApplication(app);
});
forEach(fontFiles).it("should return 200 HTTP code for file '%s'", (fontFile, done) => {
var fontUrl = "http://localhost:8080/fonts/" + fontFile;
request.get(fontUrl, function(err, res, body) {
request.get(fontUrl, function (err, res, body) {
expect(res.statusCode).to.equal(200);
done();
});

View File

@@ -6,7 +6,7 @@
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed.
*
*/
*/
const Application = require("spectron").Application;
const assert = require("assert");
@@ -14,12 +14,12 @@ const chai = require("chai");
const chaiAsPromised = require("chai-as-promised");
const path = require("path");
global.before(function() {
global.before(function () {
chai.should();
chai.use(chaiAsPromised);
});
exports.getElectronPath = function() {
exports.getElectronPath = function () {
var electronPath = path.join(__dirname, "..", "..", "node_modules", ".bin", "electron");
if (process.platform === "win32") {
electronPath += ".cmd";
@@ -28,7 +28,7 @@ exports.getElectronPath = function() {
};
// Set timeout - if this is run within Travis, increase timeout
exports.setupTimeout = function(test) {
exports.setupTimeout = function (test) {
if (process.env.CI) {
test.timeout(30000);
} else {
@@ -36,26 +36,26 @@ exports.setupTimeout = function(test) {
}
};
exports.startApplication = function(options) {
exports.startApplication = function (options) {
options.path = exports.getElectronPath();
if (process.env.CI) {
options.startTimeout = 30000;
}
var app = new Application(options);
return app.start().then(function() {
return app.start().then(function () {
assert.equal(app.isRunning(), true);
chaiAsPromised.transferPromiseness = app.transferPromiseness;
return app;
});
};
exports.stopApplication = function(app) {
exports.stopApplication = function (app) {
if (!app || !app.isRunning()) {
return;
}
return app.stop().then(function() {
return app.stop().then(function () {
assert.equal(app.isRunning(), false);
});
};

View File

@@ -13,9 +13,13 @@ describe("ipWhitelist directive configuration", function () {
var app = null;
beforeEach(function () {
return helpers.startApplication({
args: ["js/electron.js"]
}).then(function (startedApp) { app = startedApp; });
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function () {
@@ -47,5 +51,4 @@ describe("ipWhitelist directive configuration", function () {
});
});
});
});

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);

View File

@@ -9,7 +9,6 @@ describe("Position of modules", function () {
var app = null;
describe("Using helloworld", function () {
after(function () {
return helpers.stopApplication(app);
});
@@ -17,14 +16,16 @@ describe("Position of modules", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/positions.js";
return helpers.startApplication({
args: ["js/electron.js"]
}).then(function (startedApp) { app = startedApp; });
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
var positions = ["top_bar", "top_left", "top_center", "top_right", "upper_third",
"middle_center", "lower_third", "bottom_left", "bottom_center", "bottom_right",
"bottom_bar", "fullscreen_above", "fullscreen_below"];
var positions = ["top_bar", "top_left", "top_center", "top_right", "upper_third", "middle_center", "lower_third", "bottom_left", "bottom_center", "bottom_right", "bottom_bar", "fullscreen_above", "fullscreen_below"];
var position;
var className;
@@ -32,8 +33,10 @@ describe("Position of modules", function () {
position = positions[idx];
className = position.replace("_", ".");
it("show text in " + position, function () {
return app.client.waitUntilWindowLoaded()
.getText("." + className).should.eventually.equal("Text in " + position);
return app.client
.waitUntilWindowLoaded()
.getText("." + className)
.should.eventually.equal("Text in " + position);
});
}
});

View File

@@ -13,9 +13,13 @@ describe("port directive configuration", function () {
var app = null;
beforeEach(function () {
return helpers.startApplication({
args: ["js/electron.js"]
}).then(function (startedApp) { app = startedApp; });
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function () {

View File

@@ -5,13 +5,13 @@ const expect = chai.expect;
const mlog = require("mocha-logger");
const translations = require("../../translations/translations.js");
const helmet = require("helmet");
const {JSDOM} = require("jsdom");
const { JSDOM } = require("jsdom");
const express = require("express");
describe("Translations", function() {
describe("Translations", function () {
let server;
before(function() {
before(function () {
const app = express();
app.use(helmet());
app.use(function (req, res, next) {
@@ -23,12 +23,12 @@ describe("Translations", function() {
server = app.listen(3000);
});
after(function() {
after(function () {
server.close();
});
it("should have a translation file in the specified path", function() {
for(let language in translations) {
it("should have a translation file in the specified path", function () {
for (let language in translations) {
const file = fs.statSync(translations[language]);
expect(file.isFile()).to.be.equal(true);
}
@@ -41,16 +41,18 @@ describe("Translations", function() {
}
};
describe("Parsing language files through the Translator class", function() {
for(let language in translations) {
it(`should parse ${language}`, function(done) {
const dom = new JSDOM(`<script>var translations = ${JSON.stringify(translations)}; var Log = {log: function(){}};</script>\
<script src="${path.join(__dirname, "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously",
resources: "usable" });
dom.window.onload = function() {
const {Translator} = dom.window;
describe("Parsing language files through the Translator class", function () {
for (let language in translations) {
it(`should parse ${language}`, function (done) {
const dom = new JSDOM(
`<script>var translations = ${JSON.stringify(translations)}; var Log = {log: function(){}};</script>\
<script src="${path.join(__dirname, "..", "..", "js", "translator.js")}">`,
{ runScripts: "dangerously", resources: "usable" }
);
dom.window.onload = function () {
const { Translator } = dom.window;
Translator.load(mmm, translations[language], false, function() {
Translator.load(mmm, translations[language], false, function () {
expect(Translator.translations[mmm.name]).to.be.an("object");
expect(Object.keys(Translator.translations[mmm.name]).length).to.be.at.least(1);
done();
@@ -60,17 +62,19 @@ describe("Translations", function() {
}
});
describe("Same keys", function() {
describe("Same keys", function () {
let base;
before(function(done) {
const dom = new JSDOM(`<script>var translations = ${JSON.stringify(translations)}; var Log = {log: function(){}};</script>\
<script src="${path.join(__dirname, "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously",
resources: "usable" });
dom.window.onload = function() {
const {Translator} = dom.window;
before(function (done) {
const dom = new JSDOM(
`<script>var translations = ${JSON.stringify(translations)}; var Log = {log: function(){}};</script>\
<script src="${path.join(__dirname, "..", "..", "js", "translator.js")}">`,
{ runScripts: "dangerously", resources: "usable" }
);
dom.window.onload = function () {
const { Translator } = dom.window;
Translator.load(mmm, translations.en, false, function() {
Translator.load(mmm, translations.en, false, function () {
base = Object.keys(Translator.translations[mmm.name]).sort();
done();
});
@@ -82,39 +86,41 @@ describe("Translations", function() {
continue;
}
describe(`Translation keys of ${language}`, function() {
describe(`Translation keys of ${language}`, function () {
let keys;
before(function(done){
const dom = new JSDOM(`<script>var translations = ${JSON.stringify(translations)}; var Log = {log: function(){}};</script>\
<script src="${path.join(__dirname, "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously",
resources: "usable" });
dom.window.onload = function() {
const {Translator} = dom.window;
before(function (done) {
const dom = new JSDOM(
`<script>var translations = ${JSON.stringify(translations)}; var Log = {log: function(){}};</script>\
<script src="${path.join(__dirname, "..", "..", "js", "translator.js")}">`,
{ runScripts: "dangerously", resources: "usable" }
);
dom.window.onload = function () {
const { Translator } = dom.window;
Translator.load(mmm, translations[language], false, function() {
Translator.load(mmm, translations[language], false, function () {
keys = Object.keys(Translator.translations[mmm.name]).sort();
done();
});
};
});
it(`${language} keys should be in base`, function() {
keys.forEach(function(key) {
it(`${language} keys should be in base`, function () {
keys.forEach(function (key) {
expect(base.indexOf(key)).to.be.at.least(0);
});
});
it(`${language} should contain all base keys`, function() {
it(`${language} should contain all base keys`, function () {
// TODO: when all translations are fixed, use
// expect(keys).to.deep.equal(base);
// instead of the try-catch-block
try {
expect(keys).to.deep.equal(base);
} catch(e) {
} catch (e) {
if (e instanceof chai.AssertionError) {
const diff = base.filter(key => !keys.includes(key));
const diff = base.filter((key) => !keys.includes(key));
mlog.pending(`Missing Translations for language ${language}: ${diff}`);
this.skip();
} else {

View File

@@ -8,16 +8,19 @@ const before = global.before;
const after = global.after;
describe("Vendors", function () {
helpers.setupTimeout(this);
var app = null;
before(function () {
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
return helpers.startApplication({
args: ["js/electron.js"]
}).then(function (startedApp) { app = startedApp; });
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
after(function () {
@@ -25,9 +28,8 @@ describe("Vendors", function () {
});
describe("Get list vendors", function () {
var vendors = require(__dirname + "/../../vendor/vendor.js");
Object.keys(vendors).forEach(vendor => {
Object.keys(vendors).forEach((vendor) => {
it(`should return 200 HTTP code for vendor "${vendor}"`, function () {
var urlVendor = "http://localhost:8080/vendor/" + vendors[vendor];
request.get(urlVendor, function (err, res, body) {
@@ -36,8 +38,8 @@ describe("Vendors", function () {
});
});
Object.keys(vendors).forEach(vendor => {
it(`should return 404 HTTP code for vendor https://localhost/"${vendor}"`, function() {
Object.keys(vendors).forEach((vendor) => {
it(`should return 404 HTTP code for vendor https://localhost/"${vendor}"`, function () {
var urlVendor = "http://localhost:8080/" + vendors[vendor];
request.get(urlVendor, function (err, res, body) {
expect(res.statusCode).to.equal(404);

View File

@@ -11,9 +11,13 @@ describe("Check configuration without modules", function () {
var app = null;
beforeEach(function () {
return helpers.startApplication({
args: ["js/electron.js"]
}).then(function (startedApp) { app = startedApp; });
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function () {
@@ -26,13 +30,10 @@ describe("Check configuration without modules", function () {
});
it("Show the message MagicMirror title", function () {
return app.client.waitUntilWindowLoaded()
.getText("#module_1_helloworld .module-content").should.eventually.equal("Magic Mirror2");
return app.client.waitUntilWindowLoaded().getText("#module_1_helloworld .module-content").should.eventually.equal("Magic Mirror2");
});
it("Show the text Michael's website", function () {
return app.client.waitUntilWindowLoaded()
.getText("#module_5_helloworld .module-content").should.eventually.equal("www.michaelteeuw.nl");
return app.client.waitUntilWindowLoaded().getText("#module_5_helloworld .module-content").should.eventually.equal("www.michaelteeuw.nl");
});
});