mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-29 04:29:41 +00:00
commit
aa12e6495a
@ -1,10 +1,10 @@
|
||||
{
|
||||
"extends": ["eslint:recommended", "plugin:prettier/recommended", "plugin:jsdoc/recommended"],
|
||||
"plugins": ["prettier", "jsdoc"],
|
||||
"plugins": ["prettier", "jsdoc", "jest"],
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"mocha": true,
|
||||
"jest/globals": true,
|
||||
"node": true
|
||||
},
|
||||
"globals": {
|
||||
|
2
.github/workflows/node-ci.js.yml
vendored
2
.github/workflows/node-ci.js.yml
vendored
@ -28,5 +28,5 @@ jobs:
|
||||
npm run test:prettier
|
||||
npm run test:js
|
||||
npm run test:css
|
||||
npm run test:e2e
|
||||
npm run test:unit
|
||||
npm run test:e2e
|
||||
|
@ -22,6 +22,7 @@ Special thanks to the following contributors: @B1gG, @codac, @ezeholz, @khassel,
|
||||
- Added test case for recurring calendar events
|
||||
- Added new Environment Canada provider for default WEATHER module (weather data for Canadian locations only)
|
||||
- Added list view for newsfeed module.
|
||||
- Added dev dependency jest, switching from mocha to jest
|
||||
|
||||
### Updated
|
||||
|
||||
@ -37,6 +38,8 @@ Special thanks to the following contributors: @B1gG, @codac, @ezeholz, @khassel,
|
||||
|
||||
### Removed
|
||||
|
||||
- switching from mocha to jest so removed following dev dependencies: chai, chai-as-promised, mocha, mocha-each, mocha-logger
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix calendar start function logging inconsistency.
|
||||
|
10
js/logger.js
10
js/logger.js
@ -22,7 +22,7 @@
|
||||
root.Log = factory(root.config);
|
||||
}
|
||||
})(this, function (config) {
|
||||
const logLevel = {
|
||||
let logLevel = {
|
||||
debug: Function.prototype.bind.call(console.debug, console),
|
||||
log: Function.prototype.bind.call(console.log, console),
|
||||
info: Function.prototype.bind.call(console.info, console),
|
||||
@ -32,10 +32,14 @@
|
||||
groupCollapsed: Function.prototype.bind.call(console.groupCollapsed, console),
|
||||
groupEnd: Function.prototype.bind.call(console.groupEnd, console),
|
||||
time: Function.prototype.bind.call(console.time, console),
|
||||
timeEnd: Function.prototype.bind.call(console.timeEnd, console),
|
||||
timeStamp: Function.prototype.bind.call(console.timeStamp, console)
|
||||
timeEnd: Function.prototype.bind.call(console.timeEnd, console)
|
||||
};
|
||||
|
||||
// the timeStamp instruction fails when running the tests so it is not added in test environment
|
||||
if (process.env.NODE_ENV.trim() !== "test") {
|
||||
logLevel.push({ timeStamp: Function.prototype.bind.call(console.timeStamp, console) });
|
||||
}
|
||||
|
||||
logLevel.setLogLevel = function (newLevel) {
|
||||
if (newLevel) {
|
||||
Object.keys(logLevel).forEach(function (key, index) {
|
||||
|
@ -339,7 +339,9 @@ Module.register("weatherforecast", {
|
||||
*
|
||||
* argument data object - Weather information received form openweather.org.
|
||||
*/
|
||||
processWeather: function (data) {
|
||||
processWeather: function (data, momenttz) {
|
||||
let mom = momenttz ? momenttz : moment; // Exception last.
|
||||
|
||||
// Forcast16 (paid) API endpoint provides this data. Onecall endpoint
|
||||
// does not.
|
||||
if (data.city) {
|
||||
@ -357,8 +359,8 @@ Module.register("weatherforecast", {
|
||||
var dayEnds = 17;
|
||||
|
||||
if (data.city && data.city.sunrise && data.city.sunset) {
|
||||
dayStarts = new Date(moment.unix(data.city.sunrise).locale("en").format("YYYY/MM/DD HH:mm:ss")).getHours();
|
||||
dayEnds = new Date(moment.unix(data.city.sunset).locale("en").format("YYYY/MM/DD HH:mm:ss")).getHours();
|
||||
dayStarts = new Date(mom.unix(data.city.sunrise).locale("en").format("YYYY/MM/DD HH:mm:ss")).getHours();
|
||||
dayEnds = new Date(mom.unix(data.city.sunset).locale("en").format("YYYY/MM/DD HH:mm:ss")).getHours();
|
||||
}
|
||||
|
||||
// Handle different structs between forecast16 and onecall endpoints
|
||||
@ -379,11 +381,11 @@ Module.register("weatherforecast", {
|
||||
var day;
|
||||
var hour;
|
||||
if (forecast.dt_txt) {
|
||||
day = moment(forecast.dt_txt, "YYYY-MM-DD hh:mm:ss").format("ddd");
|
||||
hour = new Date(moment(forecast.dt_txt).locale("en").format("YYYY-MM-DD HH:mm:ss")).getHours();
|
||||
day = mom(forecast.dt_txt, "YYYY-MM-DD hh:mm:ss").format("ddd");
|
||||
hour = new Date(mom(forecast.dt_txt).locale("en").format("YYYY-MM-DD HH:mm:ss")).getHours();
|
||||
} else {
|
||||
day = moment(forecast.dt, "X").format("ddd");
|
||||
hour = new Date(moment(forecast.dt, "X")).getHours();
|
||||
day = mom(forecast.dt, "X").format("ddd");
|
||||
hour = new Date(mom(forecast.dt, "X")).getHours();
|
||||
}
|
||||
|
||||
if (day !== lastDay) {
|
||||
@ -392,7 +394,7 @@ Module.register("weatherforecast", {
|
||||
icon: this.config.iconTable[forecast.weather[0].icon],
|
||||
maxTemp: this.roundValue(forecast.temp.max),
|
||||
minTemp: this.roundValue(forecast.temp.min),
|
||||
rain: this.processRain(forecast, forecastList)
|
||||
rain: this.processRain(forecast, forecastList, mom)
|
||||
};
|
||||
this.forecast.push(forecastData);
|
||||
lastDay = day;
|
||||
@ -482,16 +484,18 @@ Module.register("weatherforecast", {
|
||||
* That object has a property "3h" which contains the amount of rain since the previous forecast in the list.
|
||||
* This code finds all forecasts that is for the same day and sums the amount of rain and returns that.
|
||||
*/
|
||||
processRain: function (forecast, allForecasts) {
|
||||
processRain: function (forecast, allForecasts, momenttz) {
|
||||
let mom = momenttz ? momenttz : moment; // Exception last.
|
||||
|
||||
//If the amount of rain actually is a number, return it
|
||||
if (!isNaN(forecast.rain)) {
|
||||
return forecast.rain;
|
||||
}
|
||||
|
||||
//Find all forecasts that is for the same day
|
||||
var checkDateTime = forecast.dt_txt ? moment(forecast.dt_txt, "YYYY-MM-DD hh:mm:ss") : moment(forecast.dt, "X");
|
||||
var checkDateTime = forecast.dt_txt ? mom(forecast.dt_txt, "YYYY-MM-DD hh:mm:ss") : mom(forecast.dt, "X");
|
||||
var daysForecasts = allForecasts.filter(function (item) {
|
||||
var itemDateTime = item.dt_txt ? moment(item.dt_txt, "YYYY-MM-DD hh:mm:ss") : moment(item.dt, "X");
|
||||
var itemDateTime = item.dt_txt ? mom(item.dt_txt, "YYYY-MM-DD hh:mm:ss") : mom(item.dt, "X");
|
||||
return itemDateTime.isSame(checkDateTime, "day") && item.rain instanceof Object;
|
||||
});
|
||||
|
||||
|
2847
package-lock.json
generated
2847
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
51
package.json
51
package.json
@ -10,10 +10,10 @@
|
||||
"install": "echo \"Installing vendor files ...\n\" && cd vendor && npm install --loglevel=error",
|
||||
"install-fonts": "echo \"Installing fonts ...\n\" && cd fonts && npm install --loglevel=error",
|
||||
"postinstall": "npm run install-fonts && echo \"MagicMirror installation finished successfully! \n\"",
|
||||
"test": "NODE_ENV=test mocha tests --recursive",
|
||||
"test:coverage": "NODE_ENV=test nyc --reporter=lcov --reporter=text mocha tests --recursive --timeout=3000",
|
||||
"test:e2e": "NODE_ENV=test mocha tests/e2e --recursive",
|
||||
"test:unit": "NODE_ENV=test mocha tests/unit --recursive",
|
||||
"test": "NODE_ENV=test jest -i",
|
||||
"test:coverage": "NODE_ENV=test nyc --reporter=lcov --reporter=text jest -i",
|
||||
"test:e2e": "NODE_ENV=test jest --selectProjects e2e -i",
|
||||
"test:unit": "NODE_ENV=test jest --selectProjects unit -i",
|
||||
"test:prettier": "prettier . --check",
|
||||
"test:js": "eslint js/**/*.js modules/default/**/*.js clientonly/*.js serveronly/*.js translations/*.js vendor/*.js tests/**/*.js config/* --config .eslintrc.json --quiet",
|
||||
"test:css": "stylelint css/main.css modules/default/**/*.css --config .stylelintrc.json",
|
||||
@ -45,18 +45,15 @@
|
||||
},
|
||||
"homepage": "https://magicmirror.builders",
|
||||
"devDependencies": {
|
||||
"chai": "^4.3.4",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-jsdoc": "^35.1.3",
|
||||
"eslint-plugin-jsdoc": "^35.2.0",
|
||||
"eslint-plugin-prettier": "^3.4.0",
|
||||
"eslint-plugin-jest": "^24.3.6",
|
||||
"express-basic-auth": "^1.2.0",
|
||||
"husky": "^6.0.0",
|
||||
"jest": "27.0.4",
|
||||
"jsdom": "^16.6.0",
|
||||
"lodash": "^4.17.21",
|
||||
"mocha": "^9.0.0",
|
||||
"mocha-each": "^2.0.1",
|
||||
"mocha-logger": "^1.0.7",
|
||||
"nyc": "^15.1.0",
|
||||
"prettier": "^2.3.1",
|
||||
"pretty-quick": "^3.1.0",
|
||||
@ -68,7 +65,7 @@
|
||||
"stylelint-prettier": "^1.2.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"electron": "^11.4.7"
|
||||
"electron": "^11.4.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"colors": "^1.4.0",
|
||||
@ -84,7 +81,7 @@
|
||||
"moment": "^2.29.1",
|
||||
"node-fetch": "^2.6.1",
|
||||
"node-ical": "^0.13.0",
|
||||
"simple-git": "^2.39.1",
|
||||
"simple-git": "^2.40.0",
|
||||
"socket.io": "^4.1.2"
|
||||
},
|
||||
"_moduleAliases": {
|
||||
@ -93,5 +90,35 @@
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"jest": {
|
||||
"verbose": true,
|
||||
"projects": [
|
||||
{
|
||||
"displayName": "unit",
|
||||
"testMatch": [
|
||||
"**/tests/unit/**/*.[jt]s?(x)"
|
||||
],
|
||||
"testPathIgnorePatterns": [
|
||||
"<rootDir>/tests/unit/setup_unit.js"
|
||||
],
|
||||
"setupFiles": [
|
||||
"<rootDir>/tests/unit/setup_unit.js"
|
||||
],
|
||||
"moduleNameMapper": {
|
||||
"logger": "<rootDir>/js/logger.js"
|
||||
}
|
||||
},
|
||||
{
|
||||
"displayName": "e2e",
|
||||
"testMatch": [
|
||||
"**/tests/e2e/**/*.[jt]s?(x)"
|
||||
],
|
||||
"testPathIgnorePatterns": [
|
||||
"<rootDir>/tests/e2e/modules/mocks",
|
||||
"<rootDir>/tests/e2e/global-setup.js"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +1,17 @@
|
||||
const helpers = require("./global-setup");
|
||||
const expect = require("chai").expect;
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
|
||||
describe("Development console tests", function () {
|
||||
// FIXME: This tests fail and crash another tests
|
||||
// Suspect problem with window focus
|
||||
return false;
|
||||
|
||||
/* eslint-disable */
|
||||
helpers.setupTimeout(this);
|
||||
|
||||
let app = null;
|
||||
|
||||
before(function () {
|
||||
beforeAll(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 () {
|
||||
beforeAll(function () {
|
||||
return helpers
|
||||
.startApplication({
|
||||
args: ["js/electron.js"]
|
||||
@ -30,33 +21,35 @@ describe("Development console tests", function () {
|
||||
});
|
||||
});
|
||||
|
||||
after(function () {
|
||||
afterAll(function () {
|
||||
return helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
it("should not open dev console when absent", function () {
|
||||
return expect(app.browserWindow.isDevToolsOpened()).to.eventually.equal(false);
|
||||
it("should not open dev console when absent", async function () {
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
return expect(await app.browserWindow.isDevToolsOpened()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("With 'dev' commandline argument", function () {
|
||||
before(function () {
|
||||
return helpers
|
||||
.startApplication({
|
||||
args: ["js/electron.js", "dev"]
|
||||
})
|
||||
.then(function (startedApp) {
|
||||
app = startedApp;
|
||||
});
|
||||
});
|
||||
// describe("With 'dev' commandline argument", function () {
|
||||
// beforeAll(function () {
|
||||
// return helpers
|
||||
// .startApplication({
|
||||
// args: ["js/electron.js", "dev"]
|
||||
// })
|
||||
// .then(function (startedApp) {
|
||||
// app = startedApp;
|
||||
// });
|
||||
// });
|
||||
|
||||
after(function () {
|
||||
return helpers.stopApplication(app);
|
||||
});
|
||||
// afterAll(function () {
|
||||
// return helpers.stopApplication(app);
|
||||
// });
|
||||
|
||||
it("should open dev console when provided", function () {
|
||||
return expect(app.browserWindow.isDevToolsOpened()).to.eventually.equal(true);
|
||||
});
|
||||
});
|
||||
/* eslint-enable */
|
||||
// it("should open dev console when provided", async function () {
|
||||
// expect(await app.client.getWindowCount()).toBe(2);
|
||||
// await app.client.waitUntilWindowLoaded();
|
||||
// return expect(await app.browserWindow.isDevToolsOpened()).toBe(true);
|
||||
// });
|
||||
// });
|
||||
});
|
||||
|
@ -1,18 +1,12 @@
|
||||
const helpers = require("./global-setup");
|
||||
const fetch = require("node-fetch");
|
||||
const expect = require("chai").expect;
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
const beforeEach = global.beforeEach;
|
||||
const afterEach = global.afterEach;
|
||||
|
||||
describe("Electron app environment", function () {
|
||||
helpers.setupTimeout(this);
|
||||
|
||||
let app = null;
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
|
||||
});
|
||||
@ -34,27 +28,27 @@ describe("Electron app environment", function () {
|
||||
it("should open a browserwindow", async function () {
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
app.browserWindow.focus();
|
||||
expect(await app.client.getWindowCount()).to.equal(1);
|
||||
expect(await app.browserWindow.isMinimized()).to.be.false;
|
||||
expect(await app.browserWindow.isDevToolsOpened()).to.be.false;
|
||||
expect(await app.browserWindow.isVisible()).to.be.true;
|
||||
expect(await app.browserWindow.isFocused()).to.be.true;
|
||||
expect(await app.client.getWindowCount()).toBe(1);
|
||||
expect(await app.browserWindow.isMinimized()).toBe(false);
|
||||
expect(await app.browserWindow.isDevToolsOpened()).toBe(false);
|
||||
expect(await app.browserWindow.isVisible()).toBe(true);
|
||||
expect(await app.browserWindow.isFocused()).toBe(true);
|
||||
const bounds = await app.browserWindow.getBounds();
|
||||
expect(bounds.width).to.be.above(0);
|
||||
expect(bounds.height).to.be.above(0);
|
||||
expect(await app.browserWindow.getTitle()).to.equal("MagicMirror²");
|
||||
expect(bounds.width).toBeGreaterThan(0);
|
||||
expect(bounds.height).toBeGreaterThan(0);
|
||||
expect(await app.browserWindow.getTitle()).toBe("MagicMirror²");
|
||||
});
|
||||
|
||||
it("get request from http://localhost:8080 should return 200", function (done) {
|
||||
fetch("http://localhost:8080").then((res) => {
|
||||
expect(res.status).to.equal(200);
|
||||
expect(res.status).toBe(200);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("get request from http://localhost:8080/nothing should return 404", function (done) {
|
||||
fetch("http://localhost:8080/nothing").then((res) => {
|
||||
expect(res.status).to.equal(404);
|
||||
expect(res.status).toBe(404);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -1,9 +1,5 @@
|
||||
const helpers = require("./global-setup");
|
||||
const fetch = require("node-fetch");
|
||||
const expect = require("chai").expect;
|
||||
const forEach = require("mocha-each");
|
||||
|
||||
const describe = global.describe;
|
||||
|
||||
describe("All font files from roboto.css should be downloadable", function () {
|
||||
helpers.setupTimeout(this);
|
||||
@ -21,7 +17,7 @@ describe("All font files from roboto.css should be downloadable", function () {
|
||||
match = regex.exec(fileContent);
|
||||
}
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/without_modules.js";
|
||||
|
||||
@ -34,14 +30,14 @@ describe("All font files from roboto.css should be downloadable", function () {
|
||||
});
|
||||
});
|
||||
|
||||
after(function () {
|
||||
afterAll(function () {
|
||||
return helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
forEach(fontFiles).it("should return 200 HTTP code for file '%s'", (fontFile, done) => {
|
||||
test.each(fontFiles)("should return 200 HTTP code for file '%s'", (fontFile, done) => {
|
||||
const fontUrl = "http://localhost:8080/fonts/" + fontFile;
|
||||
fetch(fontUrl).then((res) => {
|
||||
expect(res.status).to.equal(200);
|
||||
expect(res.status).toBe(200);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -6,14 +6,8 @@
|
||||
*/
|
||||
const Application = require("spectron").Application;
|
||||
const assert = require("assert");
|
||||
const chai = require("chai");
|
||||
const chaiAsPromised = require("chai-as-promised");
|
||||
const path = require("path");
|
||||
|
||||
global.before(function () {
|
||||
chai.should();
|
||||
chai.use(chaiAsPromised);
|
||||
});
|
||||
const EventEmitter = require("events");
|
||||
|
||||
exports.getElectronPath = function () {
|
||||
let electronPath = path.join(__dirname, "..", "..", "node_modules", ".bin", "electron");
|
||||
@ -23,16 +17,19 @@ exports.getElectronPath = function () {
|
||||
return electronPath;
|
||||
};
|
||||
|
||||
// Set timeout - if this is run within Travis, increase timeout
|
||||
// Set timeout - if this is run as CI Job, increase timeout
|
||||
exports.setupTimeout = function (test) {
|
||||
if (process.env.CI) {
|
||||
test.timeout(30000);
|
||||
jest.setTimeout(30000);
|
||||
} else {
|
||||
test.timeout(10000);
|
||||
jest.setTimeout(10000);
|
||||
}
|
||||
};
|
||||
|
||||
exports.startApplication = function (options) {
|
||||
const emitter = new EventEmitter();
|
||||
emitter.setMaxListeners(100);
|
||||
|
||||
options.path = exports.getElectronPath();
|
||||
if (process.env.CI) {
|
||||
options.startTimeout = 30000;
|
||||
@ -41,7 +38,6 @@ exports.startApplication = function (options) {
|
||||
const app = new Application(options);
|
||||
return app.start().then(function () {
|
||||
assert.strictEqual(app.isRunning(), true);
|
||||
chaiAsPromised.transferPromiseness = app.transferPromiseness;
|
||||
return app;
|
||||
});
|
||||
};
|
||||
|
@ -1,11 +1,5 @@
|
||||
const helpers = require("./global-setup");
|
||||
const fetch = require("node-fetch");
|
||||
const expect = require("chai").expect;
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
const beforeEach = global.beforeEach;
|
||||
const afterEach = global.afterEach;
|
||||
|
||||
describe("ipWhitelist directive configuration", function () {
|
||||
helpers.setupTimeout(this);
|
||||
@ -27,28 +21,28 @@ describe("ipWhitelist directive configuration", function () {
|
||||
});
|
||||
|
||||
describe("Set ipWhitelist without access", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/noIpWhiteList.js";
|
||||
});
|
||||
|
||||
it("should return 403", function (done) {
|
||||
fetch("http://localhost:8080").then((res) => {
|
||||
expect(res.status).to.equal(403);
|
||||
expect(res.status).toBe(403);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Set ipWhitelist []", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/empty_ipWhiteList.js";
|
||||
});
|
||||
|
||||
it("should return 200", function (done) {
|
||||
fetch("http://localhost:8080").then((res) => {
|
||||
expect(res.status).to.equal(200);
|
||||
expect(res.status).toBe(200);
|
||||
done();
|
||||
});
|
||||
});
|
@ -1,10 +1,5 @@
|
||||
const helpers = require("../global-setup");
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
const beforeEach = global.beforeEach;
|
||||
const afterEach = global.afterEach;
|
||||
|
||||
describe("Alert module", function () {
|
||||
helpers.setupTimeout(this);
|
||||
|
||||
@ -25,7 +20,7 @@ describe("Alert module", function () {
|
||||
});
|
||||
|
||||
describe("Default configuration", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/alert/default.js";
|
||||
});
|
||||
|
@ -1,11 +1,5 @@
|
||||
const helpers = require("../global-setup");
|
||||
const serverBasicAuth = require("../../servers/basic-auth.js");
|
||||
const expect = require("chai").expect;
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
const beforeEach = global.beforeEach;
|
||||
const afterEach = global.afterEach;
|
||||
|
||||
describe("Calendar module", function () {
|
||||
helpers.setupTimeout(this);
|
||||
@ -27,7 +21,7 @@ describe("Calendar module", function () {
|
||||
});
|
||||
|
||||
describe("Default configuration", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/default.js";
|
||||
});
|
||||
@ -35,18 +29,18 @@ describe("Calendar module", function () {
|
||||
it("should show the default maximumEntries of 10", async () => {
|
||||
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
||||
const events = await app.client.$$(".calendar .event");
|
||||
return expect(events.length).equals(10);
|
||||
return expect(events.length).toBe(10);
|
||||
});
|
||||
|
||||
it("should show the default calendar symbol in each event", async () => {
|
||||
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
||||
const icons = await app.client.$$(".calendar .event .fa-calendar");
|
||||
return expect(icons.length).not.equals(0);
|
||||
return expect(icons.length).not.toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Custom configuration", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/custom.js";
|
||||
});
|
||||
@ -54,30 +48,30 @@ describe("Calendar module", function () {
|
||||
it("should show the custom maximumEntries of 4", async () => {
|
||||
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
||||
const events = await app.client.$$(".calendar .event");
|
||||
return expect(events.length).equals(4);
|
||||
return expect(events.length).toBe(4);
|
||||
});
|
||||
|
||||
it("should show the custom calendar symbol in each event", async () => {
|
||||
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
||||
const icons = await app.client.$$(".calendar .event .fa-birthday-cake");
|
||||
return expect(icons.length).equals(4);
|
||||
return expect(icons.length).toBe(4);
|
||||
});
|
||||
|
||||
it("should show two custom icons for repeating events", async () => {
|
||||
await app.client.waitUntilTextExists(".calendar", "TestEventRepeat", 10000);
|
||||
const icons = await app.client.$$(".calendar .event .fa-undo");
|
||||
return expect(icons.length).equals(2);
|
||||
return expect(icons.length).toBe(2);
|
||||
});
|
||||
|
||||
it("should show two custom icons for day events", async () => {
|
||||
await app.client.waitUntilTextExists(".calendar", "TestEventDay", 10000);
|
||||
const icons = await app.client.$$(".calendar .event .fa-calendar-day");
|
||||
return expect(icons.length).equals(2);
|
||||
return expect(icons.length).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Recurring event", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/recurring.js";
|
||||
});
|
||||
@ -85,18 +79,18 @@ describe("Calendar module", function () {
|
||||
it("should show the recurring birthday event 6 times", async () => {
|
||||
await app.client.waitUntilTextExists(".calendar", "Mar 25th", 10000);
|
||||
const events = await app.client.$$(".calendar .event");
|
||||
return expect(events.length).equals(6);
|
||||
return expect(events.length).toBe(6);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Changed port", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
serverBasicAuth.listen(8010);
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/changed-port.js";
|
||||
});
|
||||
|
||||
after(function (done) {
|
||||
afterAll(function (done) {
|
||||
serverBasicAuth.close(done());
|
||||
});
|
||||
|
||||
@ -106,7 +100,7 @@ describe("Calendar module", function () {
|
||||
});
|
||||
|
||||
describe("Basic auth", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/basic-auth.js";
|
||||
});
|
||||
@ -117,7 +111,7 @@ describe("Calendar module", function () {
|
||||
});
|
||||
|
||||
describe("Basic auth by default", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/auth-default.js";
|
||||
});
|
||||
@ -128,7 +122,7 @@ describe("Calendar module", function () {
|
||||
});
|
||||
|
||||
describe("Basic auth backward compatibility configuration: DEPRECATED", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/old-basic-auth.js";
|
||||
});
|
||||
@ -139,13 +133,13 @@ describe("Calendar module", function () {
|
||||
});
|
||||
|
||||
describe("Fail Basic auth", function () {
|
||||
before(function () {
|
||||
beforeAll(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) {
|
||||
afterAll(function (done) {
|
||||
serverBasicAuth.close(done());
|
||||
});
|
||||
|
||||
|
@ -1,15 +1,17 @@
|
||||
const helpers = require("../global-setup");
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
const beforeEach = global.beforeEach;
|
||||
const afterEach = global.afterEach;
|
||||
|
||||
describe("Clock set to spanish language module", function () {
|
||||
helpers.setupTimeout(this);
|
||||
|
||||
let app = null;
|
||||
|
||||
testMatch = async function (element, regex) {
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
const elem = await app.client.$(element);
|
||||
const txt = await elem.getText(element);
|
||||
return expect(txt).toMatch(regex);
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
return helpers
|
||||
.startApplication({
|
||||
@ -25,66 +27,60 @@ describe("Clock set to spanish language module", function () {
|
||||
});
|
||||
|
||||
describe("with default 24hr clock config", function () {
|
||||
before(function () {
|
||||
beforeAll(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", async 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}$/;
|
||||
const elem = await app.client.$(".clock .date");
|
||||
return elem.getText(".clock .date").should.eventually.match(dateRegex);
|
||||
return testMatch(".clock .date", dateRegex);
|
||||
});
|
||||
|
||||
it("shows time in 24hr format", async function () {
|
||||
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
|
||||
const elem = await app.client.$(".clock .time");
|
||||
return elem.getText(".clock .time").should.eventually.match(timeRegex);
|
||||
return testMatch(".clock .time", timeRegex);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with default 12hr clock config", function () {
|
||||
before(function () {
|
||||
beforeAll(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", async 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}$/;
|
||||
const elem = await app.client.$(".clock .date");
|
||||
return elem.getText(".clock .date").should.eventually.match(dateRegex);
|
||||
return testMatch(".clock .date", dateRegex);
|
||||
});
|
||||
|
||||
it("shows time in 12hr format", async function () {
|
||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
||||
const elem = await app.client.$(".clock .time");
|
||||
return elem.getText(".clock .time").should.eventually.match(timeRegex);
|
||||
return testMatch(".clock .time", timeRegex);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with showPeriodUpper config enabled", function () {
|
||||
before(function () {
|
||||
beforeAll(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", async function () {
|
||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
||||
const elem = await app.client.$(".clock .time");
|
||||
return elem.getText(".clock .time").should.eventually.match(timeRegex);
|
||||
return testMatch(".clock .time", timeRegex);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with showWeek config enabled", function () {
|
||||
before(function () {
|
||||
beforeAll(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", async function () {
|
||||
const weekRegex = /^Semana [0-9]{1,2}$/;
|
||||
const elem = await app.client.$(".clock .week");
|
||||
elem.getText(".clock .week").should.eventually.match(weekRegex);
|
||||
return testMatch(".clock .week", weekRegex);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,17 +1,18 @@
|
||||
const helpers = require("../global-setup");
|
||||
const expect = require("chai").expect;
|
||||
const moment = require("moment");
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
const beforeEach = global.beforeEach;
|
||||
const afterEach = global.afterEach;
|
||||
|
||||
describe("Clock module", function () {
|
||||
helpers.setupTimeout(this);
|
||||
|
||||
let app = null;
|
||||
|
||||
testMatch = async function (element, regex) {
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
const elem = await app.client.$(element);
|
||||
const txt = await elem.getText(element);
|
||||
return expect(txt).toMatch(regex);
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
return helpers
|
||||
.startApplication({
|
||||
@ -27,99 +28,94 @@ describe("Clock module", function () {
|
||||
});
|
||||
|
||||
describe("with default 24hr clock config", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_24hr.js";
|
||||
});
|
||||
|
||||
it("should show the date in the correct format", async 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}$/;
|
||||
const elem = await app.client.$(".clock .date");
|
||||
return elem.getText(".clock .date").should.eventually.match(dateRegex);
|
||||
return testMatch(".clock .date", dateRegex);
|
||||
});
|
||||
|
||||
it("should show the time in 24hr format", async function () {
|
||||
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
|
||||
const elem = await app.client.$(".clock .time");
|
||||
return elem.getText(".clock .time").should.eventually.match(timeRegex);
|
||||
return testMatch(".clock .time", timeRegex);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with default 12hr clock config", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_12hr.js";
|
||||
});
|
||||
|
||||
it("should show the date in the correct format", async 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}$/;
|
||||
const elem = await app.client.$(".clock .date");
|
||||
return elem.getText(".clock .date").should.eventually.match(dateRegex);
|
||||
return testMatch(".clock .date", dateRegex);
|
||||
});
|
||||
|
||||
it("should show the time in 12hr format", async function () {
|
||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
||||
const elem = await app.client.$(".clock .time");
|
||||
return elem.getText(".clock .time").should.eventually.match(timeRegex);
|
||||
return testMatch(".clock .time", timeRegex);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with showPeriodUpper config enabled", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showPeriodUpper.js";
|
||||
});
|
||||
|
||||
it("should show 12hr time with upper case AM/PM", async function () {
|
||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
||||
const elem = await app.client.$(".clock .time");
|
||||
return elem.getText(".clock .time").should.eventually.match(timeRegex);
|
||||
return testMatch(".clock .time", timeRegex);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with displaySeconds config disabled", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_displaySeconds_false.js";
|
||||
});
|
||||
|
||||
it("should show 12hr time without seconds am/pm", async function () {
|
||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
|
||||
const elem = await app.client.$(".clock .time");
|
||||
return elem.getText(".clock .time").should.eventually.match(timeRegex);
|
||||
return testMatch(".clock .time", timeRegex);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with showWeek config enabled", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showWeek.js";
|
||||
});
|
||||
|
||||
it("should show the week in the correct format", async function () {
|
||||
const weekRegex = /^Week [0-9]{1,2}$/;
|
||||
const elem = await app.client.$(".clock .week");
|
||||
return elem.getText(".clock .week").should.eventually.match(weekRegex);
|
||||
return testMatch(".clock .week", weekRegex);
|
||||
});
|
||||
|
||||
it("should show the week with the correct number of week of year", async function () {
|
||||
const currentWeekNumber = moment().week();
|
||||
const weekToShow = "Week " + currentWeekNumber;
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
const elem = await app.client.$(".clock .week");
|
||||
return elem.getText(".clock .week").should.eventually.equal(weekToShow);
|
||||
const txt = await elem.getText(".clock .week");
|
||||
return expect(txt).toBe(weekToShow);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with analog clock face enabled", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_analog.js";
|
||||
});
|
||||
|
||||
it("should show the analog clock face", async () => {
|
||||
await app.client.waitUntilWindowLoaded(10000);
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
const clock = await app.client.$$(".clockCircle");
|
||||
return expect(clock.length).equals(1);
|
||||
return expect(clock.length).toBe(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,10 +1,4 @@
|
||||
const helpers = require("../global-setup");
|
||||
const expect = require("chai").expect;
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
const beforeEach = global.beforeEach;
|
||||
const afterEach = global.afterEach;
|
||||
|
||||
describe("Compliments module", function () {
|
||||
helpers.setupTimeout(this);
|
||||
@ -26,7 +20,7 @@ describe("Compliments module", function () {
|
||||
});
|
||||
|
||||
describe("parts of days", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_parts_day.js";
|
||||
});
|
||||
@ -37,7 +31,7 @@ describe("Compliments module", function () {
|
||||
// if morning check
|
||||
const elem = await app.client.$(".compliments");
|
||||
return elem.getText(".compliments").then(function (text) {
|
||||
expect(text).to.be.oneOf(["Hi", "Good Morning", "Morning test"]);
|
||||
expect(["Hi", "Good Morning", "Morning test"]).toContain(text);
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -48,7 +42,7 @@ describe("Compliments module", function () {
|
||||
// if afternoon check
|
||||
const elem = await app.client.$(".compliments");
|
||||
return elem.getText(".compliments").then(function (text) {
|
||||
expect(text).to.be.oneOf(["Hello", "Good Afternoon", "Afternoon test"]);
|
||||
expect(["Hello", "Good Afternoon", "Afternoon test"]).toContain(text);
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -59,7 +53,7 @@ describe("Compliments module", function () {
|
||||
// if evening check
|
||||
const elem = await app.client.$(".compliments");
|
||||
return elem.getText(".compliments").then(function (text) {
|
||||
expect(text).to.be.oneOf(["Hello There", "Good Evening", "Evening test"]);
|
||||
expect(["Hello There", "Good Evening", "Evening test"]).toContain(text);
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -67,7 +61,7 @@ describe("Compliments module", function () {
|
||||
|
||||
describe("Feature anytime in compliments module", function () {
|
||||
describe("Set anytime and empty compliments for morning, evening and afternoon ", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_anytime.js";
|
||||
});
|
||||
@ -75,13 +69,13 @@ describe("Compliments module", function () {
|
||||
it("Show anytime because if configure empty parts of day compliments and set anytime compliments", async function () {
|
||||
const elem = await app.client.$(".compliments");
|
||||
return elem.getText(".compliments").then(function (text) {
|
||||
expect(text).to.be.oneOf(["Anytime here"]);
|
||||
expect(["Anytime here"]).toContain(text);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Only anytime present in configuration compliments", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_only_anytime.js";
|
||||
});
|
||||
@ -89,7 +83,7 @@ describe("Compliments module", function () {
|
||||
it("Show anytime compliments", async function () {
|
||||
const elem = await app.client.$(".compliments");
|
||||
return elem.getText(".compliments").then(function (text) {
|
||||
expect(text).to.be.oneOf(["Anytime here"]);
|
||||
expect(["Anytime here"]).toContain(text);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -97,7 +91,7 @@ describe("Compliments module", function () {
|
||||
|
||||
describe("Feature date in compliments module", function () {
|
||||
describe("Set date and empty compliments for anytime, morning, evening and afternoon", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_date.js";
|
||||
});
|
||||
@ -105,7 +99,7 @@ describe("Compliments module", function () {
|
||||
it("Show happy new year compliment on new years day", async function () {
|
||||
const elem = await app.client.$(".compliments");
|
||||
return elem.getText(".compliments").then(function (text) {
|
||||
expect(text).to.be.oneOf(["Happy new year!"]);
|
||||
expect(["Happy new year!"]).toContain(text);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,10 +1,5 @@
|
||||
const helpers = require("../global-setup");
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
const beforeEach = global.beforeEach;
|
||||
const afterEach = global.afterEach;
|
||||
|
||||
describe("Test helloworld module", function () {
|
||||
helpers.setupTimeout(this);
|
||||
|
||||
@ -25,26 +20,26 @@ describe("Test helloworld module", function () {
|
||||
});
|
||||
|
||||
describe("helloworld set config text", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/helloworld/helloworld.js";
|
||||
});
|
||||
|
||||
it("Test message helloworld module", async function () {
|
||||
const elem = await app.client.$("helloworld");
|
||||
return elem.getText(".helloworld").should.eventually.equal("Test HelloWorld Module");
|
||||
const elem = await app.client.$(".helloworld");
|
||||
return expect(await elem.getText(".helloworld")).toBe("Test HelloWorld Module");
|
||||
});
|
||||
});
|
||||
|
||||
describe("helloworld default config text", function () {
|
||||
before(function () {
|
||||
beforeAll(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", async function () {
|
||||
const elem = await app.client.$("helloworld");
|
||||
return elem.getText(".helloworld").should.eventually.equal("Hello World!");
|
||||
const elem = await app.client.$(".helloworld");
|
||||
return expect(await elem.getText(".helloworld")).toBe("Hello World!");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,10 +1,4 @@
|
||||
const helpers = require("../global-setup");
|
||||
const expect = require("chai").expect;
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
const beforeEach = global.beforeEach;
|
||||
const afterEach = global.afterEach;
|
||||
|
||||
describe("Newsfeed module", function () {
|
||||
helpers.setupTimeout(this);
|
||||
@ -26,7 +20,7 @@ describe("Newsfeed module", function () {
|
||||
});
|
||||
|
||||
describe("Default configuration", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/default.js";
|
||||
});
|
||||
|
||||
@ -41,12 +35,12 @@ describe("Newsfeed module", function () {
|
||||
it("should NOT show the newsfeed description", async () => {
|
||||
await app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "QPanel", 10000);
|
||||
const events = await app.client.$$(".newsfeed .newsfeed-desc");
|
||||
return expect(events.length).equals(0);
|
||||
return expect(events.length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Custom configuration", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/prohibited_words.js";
|
||||
});
|
||||
|
||||
@ -57,12 +51,12 @@ describe("Newsfeed module", function () {
|
||||
it("should show the newsfeed description", async () => {
|
||||
await app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "Problema VirtualBox", 10000);
|
||||
const events = await app.client.$$(".newsfeed .newsfeed-desc");
|
||||
return expect(events.length).equals(1);
|
||||
return expect(events.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Invalid configuration", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/incorrect_url.js";
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
const expect = require("chai").expect;
|
||||
const fs = require("fs");
|
||||
const moment = require("moment");
|
||||
const path = require("path");
|
||||
@ -31,7 +30,7 @@ describe("Weather module", function () {
|
||||
async function getText(element, result) {
|
||||
const elem = await getElement(element);
|
||||
return await elem.getText(element).then(function (text) {
|
||||
expect(text.trim()).to.equal(result);
|
||||
expect(text.trim()).toBe(result);
|
||||
});
|
||||
}
|
||||
|
||||
@ -42,12 +41,12 @@ describe("Weather module", function () {
|
||||
describe("Current weather", function () {
|
||||
let template;
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
template = fs.readFileSync(path.join(__dirname, "..", "..", "..", "modules", "default", "weather", "current.njk"), "utf8");
|
||||
});
|
||||
|
||||
describe("Default configuration", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/currentweather_default.js";
|
||||
});
|
||||
|
||||
@ -94,7 +93,7 @@ describe("Weather module", function () {
|
||||
});
|
||||
|
||||
describe("Compliments Integration", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/currentweather_compliments.js";
|
||||
});
|
||||
|
||||
@ -107,7 +106,7 @@ describe("Weather module", function () {
|
||||
});
|
||||
|
||||
describe("Configuration Options", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/currentweather_options.js";
|
||||
});
|
||||
|
||||
@ -124,7 +123,7 @@ describe("Weather module", function () {
|
||||
|
||||
const elem = await getElement(".weather .normal.medium sup i.fa-long-arrow-up");
|
||||
return elem.getHTML(".weather .normal.medium sup i.fa-long-arrow-up").then(function (text) {
|
||||
expect(text).to.include("transform:rotate(250deg);");
|
||||
expect(text).toContain("transform:rotate(250deg);");
|
||||
});
|
||||
});
|
||||
|
||||
@ -144,7 +143,7 @@ describe("Weather module", function () {
|
||||
});
|
||||
|
||||
describe("Current weather units", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/currentweather_units.js";
|
||||
});
|
||||
|
||||
@ -185,12 +184,12 @@ describe("Weather module", function () {
|
||||
describe("Weather Forecast", function () {
|
||||
let template;
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
template = fs.readFileSync(path.join(__dirname, "..", "..", "..", "modules", "default", "weather", "forecast.njk"), "utf8");
|
||||
});
|
||||
|
||||
describe("Default configuration", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/forecastweather_default.js";
|
||||
});
|
||||
|
||||
@ -248,13 +247,13 @@ describe("Weather module", function () {
|
||||
|
||||
for (const [index, opacity] of opacities.entries()) {
|
||||
const html = await elem.getHTML(`.weather table.small tr:nth-child(${index + 1})`);
|
||||
expect(html).to.includes(`<tr style="opacity: ${opacity};">`);
|
||||
expect(html).toContain(`<tr style="opacity: ${opacity};">`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("Configuration Options", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/forecastweather_options.js";
|
||||
});
|
||||
|
||||
@ -271,12 +270,12 @@ describe("Weather module", function () {
|
||||
|
||||
const rows = await app.client.$$(".weather table.myTableClass tr.colored");
|
||||
|
||||
expect(rows.length).to.be.equal(5);
|
||||
expect(rows.length).toBe(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Forecast weather units", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/forecastweather_units.js";
|
||||
});
|
||||
|
||||
|
@ -1,8 +1,5 @@
|
||||
const helpers = require("./global-setup");
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
|
||||
describe("Display of modules", function () {
|
||||
helpers.setupTimeout(this);
|
||||
|
||||
@ -23,19 +20,19 @@ describe("Display of modules", function () {
|
||||
});
|
||||
|
||||
describe("Using helloworld", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/display.js";
|
||||
});
|
||||
|
||||
it("should show the test header", async () => {
|
||||
const elem = await app.client.$("#module_0_helloworld .module-header", 10000);
|
||||
return elem.getText("#module_0_helloworld .module-header").should.eventually.equal("TEST_HEADER");
|
||||
return expect(await elem.getText("#module_0_helloworld .module-header")).toBe("TEST_HEADER");
|
||||
});
|
||||
|
||||
it("should show no header if no header text is specified", async () => {
|
||||
const elem = await app.client.$("#module_1_helloworld .module-header", 10000);
|
||||
return elem.getText("#module_1_helloworld .module-header").should.eventually.equal(false);
|
||||
return expect(await elem.getText("#module_1_helloworld .module-header")).toBe("");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,19 +1,16 @@
|
||||
const helpers = require("./global-setup");
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
|
||||
describe("Position of modules", function () {
|
||||
helpers.setupTimeout(this);
|
||||
|
||||
let app = null;
|
||||
|
||||
describe("Using helloworld", function () {
|
||||
after(function () {
|
||||
afterAll(function () {
|
||||
return helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/positions.js";
|
||||
return helpers
|
||||
@ -31,7 +28,9 @@ describe("Position of modules", function () {
|
||||
const className = position.replace("_", ".");
|
||||
it("should show text in " + position, function () {
|
||||
return app.client.$("." + className).then((result) => {
|
||||
return result.getText("." + className).should.eventually.equal("Text in " + position);
|
||||
return result.getText("." + className).then((text) => {
|
||||
return expect(text).toContain("Text in " + position);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -1,11 +1,5 @@
|
||||
const helpers = require("./global-setup");
|
||||
const fetch = require("node-fetch");
|
||||
const expect = require("chai").expect;
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
const beforeEach = global.beforeEach;
|
||||
const afterEach = global.afterEach;
|
||||
|
||||
describe("port directive configuration", function () {
|
||||
helpers.setupTimeout(this);
|
||||
@ -27,33 +21,33 @@ describe("port directive configuration", function () {
|
||||
});
|
||||
|
||||
describe("Set port 8090", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in this test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/port_8090.js";
|
||||
});
|
||||
|
||||
it("should return 200", function (done) {
|
||||
fetch("http://localhost:8090").then((res) => {
|
||||
expect(res.status).to.equal(200);
|
||||
expect(res.status).toBe(200);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Set port 8100 on environment variable MM_PORT", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_PORT = 8100;
|
||||
// Set config sample for use in this test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/port_8090.js";
|
||||
});
|
||||
|
||||
after(function () {
|
||||
afterAll(function () {
|
||||
delete process.env.MM_PORT;
|
||||
});
|
||||
|
||||
it("should return 200", function (done) {
|
||||
fetch("http://localhost:8100").then((res) => {
|
||||
expect(res.status).to.equal(200);
|
||||
expect(res.status).toBe(200);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,5 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const chai = require("chai");
|
||||
const expect = chai.expect;
|
||||
const mlog = require("mocha-logger");
|
||||
const translations = require("../../translations/translations.js");
|
||||
const helmet = require("helmet");
|
||||
const { JSDOM } = require("jsdom");
|
||||
@ -12,7 +9,7 @@ const sinon = require("sinon");
|
||||
describe("Translations", function () {
|
||||
let server;
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
const app = express();
|
||||
app.use(helmet());
|
||||
app.use(function (req, res, next) {
|
||||
@ -24,14 +21,14 @@ describe("Translations", function () {
|
||||
server = app.listen(3000);
|
||||
});
|
||||
|
||||
after(function () {
|
||||
afterAll(function () {
|
||||
server.close();
|
||||
});
|
||||
|
||||
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);
|
||||
expect(file.isFile()).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
@ -59,9 +56,9 @@ describe("Translations", function () {
|
||||
const loaded = sinon.stub();
|
||||
MMM.loadTranslations(loaded);
|
||||
|
||||
expect(loaded.callCount).to.equal(1);
|
||||
expect(Translator.load.args.length).to.equal(1);
|
||||
expect(Translator.load.calledWith(MMM, "translations/en.json", false, sinon.match.func)).to.be.true;
|
||||
expect(loaded.callCount).toBe(1);
|
||||
expect(Translator.load.args.length).toBe(1);
|
||||
expect(Translator.load.calledWith(MMM, "translations/en.json", false, sinon.match.func)).toBe(true);
|
||||
|
||||
done();
|
||||
};
|
||||
@ -78,10 +75,10 @@ describe("Translations", function () {
|
||||
const loaded = sinon.stub();
|
||||
MMM.loadTranslations(loaded);
|
||||
|
||||
expect(loaded.callCount).to.equal(1);
|
||||
expect(Translator.load.args.length).to.equal(2);
|
||||
expect(Translator.load.calledWith(MMM, "translations/de.json", false, sinon.match.func)).to.be.true;
|
||||
expect(Translator.load.calledWith(MMM, "translations/en.json", true, sinon.match.func)).to.be.true;
|
||||
expect(loaded.callCount).toBe(1);
|
||||
expect(Translator.load.args.length).toBe(2);
|
||||
expect(Translator.load.calledWith(MMM, "translations/de.json", false, sinon.match.func)).toBe(true);
|
||||
expect(Translator.load.calledWith(MMM, "translations/en.json", true, sinon.match.func)).toBe(true);
|
||||
|
||||
done();
|
||||
};
|
||||
@ -99,9 +96,9 @@ describe("Translations", function () {
|
||||
const loaded = sinon.stub();
|
||||
MMM.loadTranslations(loaded);
|
||||
|
||||
expect(loaded.callCount).to.equal(1);
|
||||
expect(Translator.load.args.length).to.equal(1);
|
||||
expect(Translator.load.calledWith(MMM, "translations/en.json", true, sinon.match.func)).to.be.true;
|
||||
expect(loaded.callCount).toBe(1);
|
||||
expect(Translator.load.args.length).toBe(1);
|
||||
expect(Translator.load.calledWith(MMM, "translations/en.json", true, sinon.match.func)).toBe(true);
|
||||
|
||||
done();
|
||||
};
|
||||
@ -118,8 +115,8 @@ describe("Translations", function () {
|
||||
const loaded = sinon.stub();
|
||||
MMM.loadTranslations(loaded);
|
||||
|
||||
expect(loaded.callCount).to.equal(1);
|
||||
expect(Translator.load.callCount).to.equal(0);
|
||||
expect(loaded.callCount).toBe(1);
|
||||
expect(Translator.load.callCount).toBe(0);
|
||||
|
||||
done();
|
||||
};
|
||||
@ -145,8 +142,8 @@ describe("Translations", function () {
|
||||
const { Translator } = dom.window;
|
||||
|
||||
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);
|
||||
expect(typeof Translator.translations[mmm.name]).toBe("object");
|
||||
expect(Object.keys(Translator.translations[mmm.name]).length).toBeGreaterThanOrEqual(1);
|
||||
done();
|
||||
});
|
||||
};
|
||||
@ -156,8 +153,9 @@ describe("Translations", function () {
|
||||
|
||||
describe("Same keys", function () {
|
||||
let base;
|
||||
let missing = [];
|
||||
|
||||
before(function (done) {
|
||||
beforeAll(function (done) {
|
||||
const dom = new JSDOM(
|
||||
`<script>var translations = ${JSON.stringify(translations)}; var Log = {log: function(){}};</script>\
|
||||
<script src="file://${path.join(__dirname, "..", "..", "js", "translator.js")}">`,
|
||||
@ -173,6 +171,10 @@ describe("Translations", function () {
|
||||
};
|
||||
});
|
||||
|
||||
afterAll(function () {
|
||||
console.log(missing);
|
||||
});
|
||||
|
||||
for (let language in translations) {
|
||||
if (language === "en") {
|
||||
continue;
|
||||
@ -181,7 +183,7 @@ describe("Translations", function () {
|
||||
describe(`Translation keys of ${language}`, function () {
|
||||
let keys;
|
||||
|
||||
before(function (done) {
|
||||
beforeAll(function (done) {
|
||||
const dom = new JSDOM(
|
||||
`<script>var translations = ${JSON.stringify(translations)}; var Log = {log: function(){}};</script>\
|
||||
<script src="file://${path.join(__dirname, "..", "..", "js", "translator.js")}">`,
|
||||
@ -199,22 +201,21 @@ describe("Translations", function () {
|
||||
|
||||
it(`${language} keys should be in base`, function () {
|
||||
keys.forEach(function (key) {
|
||||
expect(base.indexOf(key)).to.be.at.least(0);
|
||||
expect(base.indexOf(key)).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
it(`${language} should contain all base keys`, function () {
|
||||
// TODO: when all translations are fixed, use
|
||||
// expect(keys).to.deep.equal(base);
|
||||
// expect(keys).toEqual(base);
|
||||
// instead of the try-catch-block
|
||||
|
||||
try {
|
||||
expect(keys).to.deep.equal(base);
|
||||
expect(keys).toEqual(base);
|
||||
} catch (e) {
|
||||
if (e instanceof chai.AssertionError) {
|
||||
if (e.message.match(/expect.*toEqual/)) {
|
||||
const diff = base.filter((key) => !keys.includes(key));
|
||||
mlog.pending(`Missing Translations for language ${language}: ${diff}`);
|
||||
this.skip();
|
||||
missing.push(`Missing Translations for language ${language}: ${diff}`);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
const helpers = require("./global-setup");
|
||||
const fetch = require("node-fetch");
|
||||
const expect = require("chai").expect;
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
const before = global.before;
|
||||
const after = global.after;
|
||||
|
||||
@ -12,7 +9,7 @@ describe("Vendors", function () {
|
||||
|
||||
let app = null;
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
|
||||
return helpers
|
||||
.startApplication({
|
||||
@ -23,26 +20,28 @@ describe("Vendors", function () {
|
||||
});
|
||||
});
|
||||
|
||||
after(function () {
|
||||
afterAll(function () {
|
||||
return helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
describe("Get list vendors", function () {
|
||||
const vendors = require(__dirname + "/../../vendor/vendor.js");
|
||||
Object.keys(vendors).forEach((vendor) => {
|
||||
it(`should return 200 HTTP code for vendor "${vendor}"`, function () {
|
||||
it(`should return 200 HTTP code for vendor "${vendor}"`, function (done) {
|
||||
const urlVendor = "http://localhost:8080/vendor/" + vendors[vendor];
|
||||
fetch(urlVendor).then((res) => {
|
||||
expect(res.status).to.equal(200);
|
||||
expect(res.status).toBe(200);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Object.keys(vendors).forEach((vendor) => {
|
||||
it(`should return 404 HTTP code for vendor https://localhost/"${vendor}"`, function () {
|
||||
it(`should return 404 HTTP code for vendor https://localhost/"${vendor}"`, function (done) {
|
||||
const urlVendor = "http://localhost:8080/" + vendors[vendor];
|
||||
fetch(urlVendor).then((res) => {
|
||||
expect(res.status).to.equal(404);
|
||||
expect(res.status).toBe(404);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,10 +1,5 @@
|
||||
const helpers = require("./global-setup");
|
||||
|
||||
const describe = global.describe;
|
||||
const it = global.it;
|
||||
const beforeEach = global.beforeEach;
|
||||
const afterEach = global.afterEach;
|
||||
|
||||
describe("Check configuration without modules", function () {
|
||||
helpers.setupTimeout(this);
|
||||
|
||||
@ -24,18 +19,18 @@ describe("Check configuration without modules", function () {
|
||||
return helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/without_modules.js";
|
||||
});
|
||||
|
||||
it("Show the message MagicMirror title", async function () {
|
||||
const elem = await app.client.$("#module_1_helloworld .module-content");
|
||||
return elem.getText("#module_1_helloworld .module-content").should.eventually.equal("Magic Mirror2");
|
||||
return expect(await elem.getText("#module_1_helloworld .module-content")).toBe("Magic Mirror2");
|
||||
});
|
||||
|
||||
it("Show the text Michael's website", async function () {
|
||||
const elem = await app.client.$("#module_5_helloworld .module-content");
|
||||
return elem.getText("#module_5_helloworld .module-content").should.eventually.equal("www.michaelteeuw.nl");
|
||||
return expect(await elem.getText("#module_5_helloworld .module-content")).toBe("www.michaelteeuw.nl");
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
const expect = require("chai").expect;
|
||||
const path = require("path");
|
||||
const { JSDOM } = require("jsdom");
|
||||
|
||||
@ -7,7 +6,7 @@ describe("File js/class", function () {
|
||||
let clone;
|
||||
let dom;
|
||||
|
||||
before(function (done) {
|
||||
beforeAll(function (done) {
|
||||
dom = new JSDOM(
|
||||
`<script>var Log = {log: function() {}};</script>\
|
||||
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "class.js")}">`,
|
||||
@ -23,43 +22,43 @@ describe("File js/class", function () {
|
||||
it("should clone object", function () {
|
||||
const expected = { name: "Rodrigo", web: "https://rodrigoramirez.com", project: "MagicMirror" };
|
||||
const obj = clone(expected);
|
||||
expect(obj).to.deep.equal(expected);
|
||||
expect(expected === obj).to.equal(false);
|
||||
expect(obj).toEqual(expected);
|
||||
expect(expected === obj).toBe(false);
|
||||
});
|
||||
|
||||
it("should clone array", function () {
|
||||
const expected = [1, null, undefined, "TEST"];
|
||||
const obj = clone(expected);
|
||||
expect(obj).to.deep.equal(expected);
|
||||
expect(expected === obj).to.equal(false);
|
||||
expect(obj).toEqual(expected);
|
||||
expect(expected === obj).toBe(false);
|
||||
});
|
||||
|
||||
it("should clone number", function () {
|
||||
let expected = 1;
|
||||
let obj = clone(expected);
|
||||
expect(obj).to.equal(expected);
|
||||
expect(obj).toBe(expected);
|
||||
|
||||
expected = 1.23;
|
||||
obj = clone(expected);
|
||||
expect(obj).to.equal(expected);
|
||||
expect(obj).toBe(expected);
|
||||
});
|
||||
|
||||
it("should clone string", function () {
|
||||
const expected = "Perfect stranger";
|
||||
const obj = clone(expected);
|
||||
expect(obj).to.equal(expected);
|
||||
expect(obj).toBe(expected);
|
||||
});
|
||||
|
||||
it("should clone undefined", function () {
|
||||
const expected = undefined;
|
||||
const obj = clone(expected);
|
||||
expect(obj).to.equal(expected);
|
||||
expect(obj).toBe(expected);
|
||||
});
|
||||
|
||||
it("should clone null", function () {
|
||||
const expected = null;
|
||||
const obj = clone(expected);
|
||||
expect(obj).to.equal(expected);
|
||||
expect(obj).toBe(expected);
|
||||
});
|
||||
|
||||
it("should clone nested object", function () {
|
||||
@ -75,34 +74,34 @@ describe("File js/class", function () {
|
||||
}
|
||||
};
|
||||
const obj = clone(expected);
|
||||
expect(obj).to.deep.equal(expected);
|
||||
expect(expected === obj).to.equal(false);
|
||||
expect(expected.versions === obj.versions).to.equal(false);
|
||||
expect(expected.properties === obj.properties).to.equal(false);
|
||||
expect(expected.properties.items === obj.properties.items).to.equal(false);
|
||||
expect(expected.properties.items[0] === obj.properties.items[0]).to.equal(false);
|
||||
expect(expected.properties.items[1] === obj.properties.items[1]).to.equal(false);
|
||||
expect(obj).toEqual(expected);
|
||||
expect(expected === obj).toBe(false);
|
||||
expect(expected.versions === obj.versions).toBe(false);
|
||||
expect(expected.properties === obj.properties).toBe(false);
|
||||
expect(expected.properties.items === obj.properties.items).toBe(false);
|
||||
expect(expected.properties.items[0] === obj.properties.items[0]).toBe(false);
|
||||
expect(expected.properties.items[1] === obj.properties.items[1]).toBe(false);
|
||||
});
|
||||
|
||||
describe("Test lockstring code", function () {
|
||||
let log;
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
log = dom.window.Log.log;
|
||||
dom.window.Log.log = function cmp(str) {
|
||||
expect(str).to.equal("lockStrings");
|
||||
expect(str).toBe("lockStrings");
|
||||
};
|
||||
});
|
||||
|
||||
after(function () {
|
||||
afterAll(function () {
|
||||
dom.window.Log.log = log;
|
||||
});
|
||||
|
||||
it("should clone object and log lockStrings", function () {
|
||||
const expected = { name: "Module", lockStrings: "stringLock" };
|
||||
const obj = clone(expected);
|
||||
expect(obj).to.deep.equal(expected);
|
||||
expect(expected === obj).to.equal(false);
|
||||
expect(obj).toEqual(expected);
|
||||
expect(expected === obj).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,16 +1,15 @@
|
||||
const expect = require("chai").expect;
|
||||
const deprecated = require("../../../js/deprecated");
|
||||
|
||||
describe("Deprecated", function () {
|
||||
it("should be an object", function () {
|
||||
expect(deprecated).to.be.an("object");
|
||||
expect(typeof deprecated).toBe("object");
|
||||
});
|
||||
|
||||
it("should contain configs array with deprecated options as strings", function () {
|
||||
expect(deprecated.configs).to.be.an("array");
|
||||
expect(Array.isArray(["deprecated.configs"])).toBe(true);
|
||||
for (let option of deprecated.configs) {
|
||||
expect(option).to.be.an("string");
|
||||
expect(typeof option).toBe("string");
|
||||
}
|
||||
expect(deprecated.configs).to.include("kioskmode");
|
||||
expect(deprecated.configs).toEqual(expect.arrayContaining(["kioskmode"]));
|
||||
});
|
||||
});
|
||||
|
@ -1,13 +1,13 @@
|
||||
const expect = require("chai").expect;
|
||||
const path = require("path");
|
||||
const helmet = require("helmet");
|
||||
const { JSDOM } = require("jsdom");
|
||||
const express = require("express");
|
||||
const sockets = new Set();
|
||||
|
||||
describe("Translator", function () {
|
||||
let server;
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
const app = express();
|
||||
app.use(helmet());
|
||||
app.use(function (req, res, next) {
|
||||
@ -17,9 +17,19 @@ describe("Translator", function () {
|
||||
app.use("/translations", express.static(path.join(__dirname, "..", "..", "..", "tests", "configs", "data")));
|
||||
|
||||
server = app.listen(3000);
|
||||
|
||||
server.on("connection", (socket) => {
|
||||
sockets.add(socket);
|
||||
});
|
||||
});
|
||||
|
||||
after(function () {
|
||||
afterAll(function () {
|
||||
for (const socket of sockets) {
|
||||
socket.destroy();
|
||||
|
||||
sockets.delete(socket);
|
||||
}
|
||||
|
||||
server.close();
|
||||
});
|
||||
|
||||
@ -70,9 +80,9 @@ describe("Translator", function () {
|
||||
const { Translator } = dom.window;
|
||||
setTranslations(Translator);
|
||||
let translation = Translator.translate({ name: "MMM-Module" }, "Hello");
|
||||
expect(translation).to.be.equal("Hallo");
|
||||
expect(translation).toBe("Hallo");
|
||||
translation = Translator.translate({ name: "MMM-Module" }, "Hello {username}", { username: "fewieden" });
|
||||
expect(translation).to.be.equal("Hallo fewieden");
|
||||
expect(translation).toBe("Hallo fewieden");
|
||||
done();
|
||||
};
|
||||
});
|
||||
@ -83,9 +93,9 @@ describe("Translator", function () {
|
||||
const { Translator } = dom.window;
|
||||
setTranslations(Translator);
|
||||
let translation = Translator.translate({ name: "MMM-Module" }, "FOO");
|
||||
expect(translation).to.be.equal("Foo");
|
||||
expect(translation).toBe("Foo");
|
||||
translation = Translator.translate({ name: "MMM-Module" }, "BAR {something}", { something: "Lorem Ipsum" });
|
||||
expect(translation).to.be.equal("Bar Lorem Ipsum");
|
||||
expect(translation).toBe("Bar Lorem Ipsum");
|
||||
done();
|
||||
};
|
||||
});
|
||||
@ -96,7 +106,7 @@ describe("Translator", function () {
|
||||
const { Translator } = dom.window;
|
||||
setTranslations(Translator);
|
||||
const translation = Translator.translate({ name: "MMM-Module" }, "A key");
|
||||
expect(translation).to.be.equal("A translation");
|
||||
expect(translation).toBe("A translation");
|
||||
done();
|
||||
};
|
||||
});
|
||||
@ -107,7 +117,7 @@ describe("Translator", function () {
|
||||
const { Translator } = dom.window;
|
||||
setTranslations(Translator);
|
||||
const translation = Translator.translate({ name: "MMM-Module" }, "Fallback");
|
||||
expect(translation).to.be.equal("core fallback");
|
||||
expect(translation).toBe("core fallback");
|
||||
done();
|
||||
};
|
||||
});
|
||||
@ -118,7 +128,7 @@ describe("Translator", function () {
|
||||
const { Translator } = dom.window;
|
||||
setTranslations(Translator);
|
||||
const translation = Translator.translate({ name: "MMM-Module" }, "Hello {username}");
|
||||
expect(translation).to.be.equal("Hallo {username}");
|
||||
expect(translation).toBe("Hallo {username}");
|
||||
done();
|
||||
};
|
||||
});
|
||||
@ -129,7 +139,7 @@ describe("Translator", function () {
|
||||
const { Translator } = dom.window;
|
||||
setTranslations(Translator);
|
||||
const translation = Translator.translate({ name: "MMM-Module" }, "MISSING");
|
||||
expect(translation).to.be.equal("MISSING");
|
||||
expect(translation).toBe("MISSING");
|
||||
done();
|
||||
};
|
||||
});
|
||||
@ -151,7 +161,7 @@ describe("Translator", function () {
|
||||
|
||||
Translator.load(mmm, file, false, function () {
|
||||
const json = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", file));
|
||||
expect(Translator.translations[mmm.name]).to.be.deep.equal(json);
|
||||
expect(Translator.translations[mmm.name]).toEqual(json);
|
||||
done();
|
||||
});
|
||||
};
|
||||
@ -165,7 +175,7 @@ describe("Translator", function () {
|
||||
|
||||
Translator.load(mmm, file, true, function () {
|
||||
const json = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", file));
|
||||
expect(Translator.translationsFallback[mmm.name]).to.be.deep.equal(json);
|
||||
expect(Translator.translationsFallback[mmm.name]).toEqual(json);
|
||||
done();
|
||||
});
|
||||
};
|
||||
@ -186,8 +196,8 @@ describe("Translator", function () {
|
||||
};
|
||||
|
||||
Translator.load(mmm, file, false, function () {
|
||||
expect(Translator.translations[mmm.name]).to.be.equal(undefined);
|
||||
expect(Translator.translationsFallback[mmm.name]).to.be.deep.equal({
|
||||
expect(Translator.translations[mmm.name]).toBe(undefined);
|
||||
expect(Translator.translationsFallback[mmm.name]).toEqual({
|
||||
Hello: "Hallo"
|
||||
});
|
||||
done();
|
||||
@ -209,8 +219,8 @@ describe("Translator", function () {
|
||||
|
||||
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
|
||||
setTimeout(function () {
|
||||
expect(Translator.coreTranslations).to.be.deep.equal(en);
|
||||
expect(Translator.coreTranslationsFallback).to.be.deep.equal(en);
|
||||
expect(Translator.coreTranslations).toEqual(en);
|
||||
expect(Translator.coreTranslationsFallback).toEqual(en);
|
||||
done();
|
||||
}, 500);
|
||||
};
|
||||
@ -228,8 +238,8 @@ describe("Translator", function () {
|
||||
|
||||
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
|
||||
setTimeout(function () {
|
||||
expect(Translator.coreTranslations).to.be.deep.equal({});
|
||||
expect(Translator.coreTranslationsFallback).to.be.deep.equal(en);
|
||||
expect(Translator.coreTranslations).toEqual({});
|
||||
expect(Translator.coreTranslationsFallback).toEqual(en);
|
||||
done();
|
||||
}, 500);
|
||||
};
|
||||
@ -249,7 +259,7 @@ describe("Translator", function () {
|
||||
|
||||
const en = require(path.join(__dirname, "..", "..", "..", "tests", "configs", "data", "en.json"));
|
||||
setTimeout(function () {
|
||||
expect(Translator.coreTranslationsFallback).to.be.deep.equal(en);
|
||||
expect(Translator.coreTranslationsFallback).toEqual(en);
|
||||
done();
|
||||
}, 500);
|
||||
};
|
||||
@ -266,7 +276,7 @@ describe("Translator", function () {
|
||||
Translator.loadCoreTranslations();
|
||||
|
||||
setTimeout(function () {
|
||||
expect(Translator.coreTranslationsFallback).to.be.deep.equal({});
|
||||
expect(Translator.coreTranslationsFallback).toEqual({});
|
||||
done();
|
||||
}, 500);
|
||||
};
|
||||
|
@ -1,4 +1,3 @@
|
||||
const expect = require("chai").expect;
|
||||
const Utils = require("../../../js/utils.js");
|
||||
const colors = require("colors/safe");
|
||||
|
||||
@ -11,29 +10,29 @@ describe("Utils", function () {
|
||||
});
|
||||
|
||||
it("should have info, warn and error properties", function () {
|
||||
expect(Utils.colors).to.have.property("info");
|
||||
expect(Utils.colors).to.have.property("warn");
|
||||
expect(Utils.colors).to.have.property("error");
|
||||
expect(Utils.colors).toHaveProperty("info");
|
||||
expect(Utils.colors).toHaveProperty("warn");
|
||||
expect(Utils.colors).toHaveProperty("error");
|
||||
});
|
||||
|
||||
it("properties should be functions", function () {
|
||||
expect(Utils.colors.info).to.be.a("function");
|
||||
expect(Utils.colors.warn).to.be.a("function");
|
||||
expect(Utils.colors.error).to.be.a("function");
|
||||
expect(typeof Utils.colors.info).toBe("function");
|
||||
expect(typeof Utils.colors.warn).toBe("function");
|
||||
expect(typeof Utils.colors.error).toBe("function");
|
||||
});
|
||||
|
||||
it("should print colored message in supported consoles", function () {
|
||||
colors.enabled = true;
|
||||
expect(Utils.colors.info("some informations")).to.be.equal("\u001b[34msome informations\u001b[39m");
|
||||
expect(Utils.colors.warn("a warning")).to.be.equal("\u001b[33ma warning\u001b[39m");
|
||||
expect(Utils.colors.error("ERROR!")).to.be.equal("\u001b[31mERROR!\u001b[39m");
|
||||
expect(Utils.colors.info("some informations")).toBe("\u001b[34msome informations\u001b[39m");
|
||||
expect(Utils.colors.warn("a warning")).toBe("\u001b[33ma warning\u001b[39m");
|
||||
expect(Utils.colors.error("ERROR!")).toBe("\u001b[31mERROR!\u001b[39m");
|
||||
});
|
||||
|
||||
it("should print message in unsupported consoles", function () {
|
||||
colors.enabled = false;
|
||||
expect(Utils.colors.info("some informations")).to.be.equal("some informations");
|
||||
expect(Utils.colors.warn("a warning")).to.be.equal("a warning");
|
||||
expect(Utils.colors.error("ERROR!")).to.be.equal("ERROR!");
|
||||
expect(Utils.colors.info("some informations")).toBe("some informations");
|
||||
expect(Utils.colors.warn("a warning")).toBe("a warning");
|
||||
expect(Utils.colors.error("ERROR!")).toBe("ERROR!");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,3 @@
|
||||
const expect = require("chai").expect;
|
||||
|
||||
global.moment = require("moment");
|
||||
|
||||
describe("Functions into modules/default/calendar/calendar.js", function () {
|
||||
@ -10,7 +8,7 @@ describe("Functions into modules/default/calendar/calendar.js", function () {
|
||||
Module.definitions[name] = moduleDefinition;
|
||||
};
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// load calendar.js
|
||||
require("../../../modules/default/calendar/calendar.js");
|
||||
});
|
||||
@ -26,63 +24,63 @@ describe("Functions into modules/default/calendar/calendar.js", function () {
|
||||
|
||||
Object.keys(words).forEach((word) => {
|
||||
it(`for '${word}' should return '${words[word]}'`, function () {
|
||||
expect(Module.definitions.calendar.capFirst(word)).to.equal(words[word]);
|
||||
expect(Module.definitions.calendar.capFirst(word)).toBe(words[word]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("getLocaleSpecification", function () {
|
||||
it("should return a valid moment.LocaleSpecification for a 12-hour format", function () {
|
||||
expect(Module.definitions.calendar.getLocaleSpecification(12)).to.deep.equal({ longDateFormat: { LT: "h:mm A" } });
|
||||
expect(Module.definitions.calendar.getLocaleSpecification(12)).toEqual({ longDateFormat: { LT: "h:mm A" } });
|
||||
});
|
||||
|
||||
it("should return a valid moment.LocaleSpecification for a 24-hour format", function () {
|
||||
expect(Module.definitions.calendar.getLocaleSpecification(24)).to.deep.equal({ longDateFormat: { LT: "HH:mm" } });
|
||||
expect(Module.definitions.calendar.getLocaleSpecification(24)).toEqual({ longDateFormat: { LT: "HH:mm" } });
|
||||
});
|
||||
|
||||
it("should return the current system locale when called without timeFormat number", function () {
|
||||
expect(Module.definitions.calendar.getLocaleSpecification()).to.deep.equal({ longDateFormat: { LT: moment.localeData().longDateFormat("LT") } });
|
||||
expect(Module.definitions.calendar.getLocaleSpecification()).toEqual({ longDateFormat: { LT: moment.localeData().longDateFormat("LT") } });
|
||||
});
|
||||
|
||||
it("should return a 12-hour longDateFormat when using the 'en' locale", function () {
|
||||
const localeBackup = moment.locale();
|
||||
moment.locale("en");
|
||||
expect(Module.definitions.calendar.getLocaleSpecification()).to.deep.equal({ longDateFormat: { LT: "h:mm A" } });
|
||||
expect(Module.definitions.calendar.getLocaleSpecification()).toEqual({ longDateFormat: { LT: "h:mm A" } });
|
||||
moment.locale(localeBackup);
|
||||
});
|
||||
|
||||
it("should return a 12-hour longDateFormat when using the 'au' locale", function () {
|
||||
const localeBackup = moment.locale();
|
||||
moment.locale("au");
|
||||
expect(Module.definitions.calendar.getLocaleSpecification()).to.deep.equal({ longDateFormat: { LT: "h:mm A" } });
|
||||
expect(Module.definitions.calendar.getLocaleSpecification()).toEqual({ longDateFormat: { LT: "h:mm A" } });
|
||||
moment.locale(localeBackup);
|
||||
});
|
||||
|
||||
it("should return a 12-hour longDateFormat when using the 'eg' locale", function () {
|
||||
const localeBackup = moment.locale();
|
||||
moment.locale("eg");
|
||||
expect(Module.definitions.calendar.getLocaleSpecification()).to.deep.equal({ longDateFormat: { LT: "h:mm A" } });
|
||||
expect(Module.definitions.calendar.getLocaleSpecification()).toEqual({ longDateFormat: { LT: "h:mm A" } });
|
||||
moment.locale(localeBackup);
|
||||
});
|
||||
|
||||
it("should return a 24-hour longDateFormat when using the 'nl' locale", function () {
|
||||
const localeBackup = moment.locale();
|
||||
moment.locale("nl");
|
||||
expect(Module.definitions.calendar.getLocaleSpecification()).to.deep.equal({ longDateFormat: { LT: "HH:mm" } });
|
||||
expect(Module.definitions.calendar.getLocaleSpecification()).toEqual({ longDateFormat: { LT: "HH:mm" } });
|
||||
moment.locale(localeBackup);
|
||||
});
|
||||
|
||||
it("should return a 24-hour longDateFormat when using the 'fr' locale", function () {
|
||||
const localeBackup = moment.locale();
|
||||
moment.locale("fr");
|
||||
expect(Module.definitions.calendar.getLocaleSpecification()).to.deep.equal({ longDateFormat: { LT: "HH:mm" } });
|
||||
expect(Module.definitions.calendar.getLocaleSpecification()).toEqual({ longDateFormat: { LT: "HH:mm" } });
|
||||
moment.locale(localeBackup);
|
||||
});
|
||||
|
||||
it("should return a 24-hour longDateFormat when using the 'uk' locale", function () {
|
||||
const localeBackup = moment.locale();
|
||||
moment.locale("uk");
|
||||
expect(Module.definitions.calendar.getLocaleSpecification()).to.deep.equal({ longDateFormat: { LT: "HH:mm" } });
|
||||
expect(Module.definitions.calendar.getLocaleSpecification()).toEqual({ longDateFormat: { LT: "HH:mm" } });
|
||||
moment.locale(localeBackup);
|
||||
});
|
||||
});
|
||||
@ -97,32 +95,32 @@ describe("Functions into modules/default/calendar/calendar.js", function () {
|
||||
|
||||
Object.keys(strings).forEach((string) => {
|
||||
it(`for '${string}' should return '${strings[string].return}'`, function () {
|
||||
expect(Module.definitions.calendar.shorten(string, strings[string].length)).to.equal(strings[string].return);
|
||||
expect(Module.definitions.calendar.shorten(string, strings[string].length)).toBe(strings[string].return);
|
||||
});
|
||||
});
|
||||
|
||||
it("should return an empty string if shorten is called with a non-string", function () {
|
||||
expect(Module.definitions.calendar.shorten(100)).to.equal("");
|
||||
expect(Module.definitions.calendar.shorten(100)).toBe("");
|
||||
});
|
||||
|
||||
it("should not shorten the string if shorten is called with a non-number maxLength", function () {
|
||||
expect(Module.definitions.calendar.shorten("This is a test string", "This is not a number")).to.equal("This is a test string");
|
||||
expect(Module.definitions.calendar.shorten("This is a test string", "This is not a number")).toBe("This is a test string");
|
||||
});
|
||||
|
||||
it("should wrap the string instead of shorten it if shorten is called with wrapEvents = true (with maxLength defined as 20)", function () {
|
||||
expect(Module.definitions.calendar.shorten("This is a wrapEvent test. Should wrap the string instead of shorten it if called with wrapEvent = true", 20, true)).to.equal(
|
||||
expect(Module.definitions.calendar.shorten("This is a wrapEvent test. Should wrap the string instead of shorten it if called with wrapEvent = true", 20, true)).toBe(
|
||||
"This is a <br>wrapEvent test. Should wrap <br>the string instead of <br>shorten it if called with <br>wrapEvent = true"
|
||||
);
|
||||
});
|
||||
|
||||
it("should wrap the string instead of shorten it if shorten is called with wrapEvents = true (without maxLength defined, default 25)", function () {
|
||||
expect(Module.definitions.calendar.shorten("This is a wrapEvent test. Should wrap the string instead of shorten it if called with wrapEvent = true", undefined, true)).to.equal(
|
||||
expect(Module.definitions.calendar.shorten("This is a wrapEvent test. Should wrap the string instead of shorten it if called with wrapEvent = true", undefined, true)).toBe(
|
||||
"This is a wrapEvent <br>test. Should wrap the string <br>instead of shorten it if called <br>with wrapEvent = true"
|
||||
);
|
||||
});
|
||||
|
||||
it("should wrap and shorten the string in the second line if called with wrapEvents = true and maxTitleLines = 2", function () {
|
||||
expect(Module.definitions.calendar.shorten("This is a wrapEvent and maxTitleLines test. Should wrap and shorten the string in the second line if called with wrapEvents = true and maxTitleLines = 2", undefined, true, 2)).to.equal(
|
||||
expect(Module.definitions.calendar.shorten("This is a wrapEvent and maxTitleLines test. Should wrap and shorten the string in the second line if called with wrapEvents = true and maxTitleLines = 2", undefined, true, 2)).toBe(
|
||||
"This is a wrapEvent and <br>maxTitleLines test. Should wrap and …"
|
||||
);
|
||||
});
|
||||
|
@ -1,11 +1,10 @@
|
||||
const expect = require("chai").expect;
|
||||
const path = require("path");
|
||||
const { JSDOM } = require("jsdom");
|
||||
|
||||
describe("Test function cmpVersions in js/module.js", function () {
|
||||
let cmp;
|
||||
|
||||
before(function (done) {
|
||||
beforeAll(function (done) {
|
||||
const dom = new JSDOM(
|
||||
`<script>var Class = {extend: function() { return {}; }};</script>\
|
||||
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "module.js")}">`,
|
||||
@ -19,14 +18,14 @@ describe("Test function cmpVersions in js/module.js", function () {
|
||||
});
|
||||
|
||||
it("should return -1 when comparing 2.1 to 2.2", function () {
|
||||
expect(cmp("2.1", "2.2")).to.equal(-1);
|
||||
expect(cmp("2.1", "2.2")).toBe(-1);
|
||||
});
|
||||
|
||||
it("should be return 0 when comparing 2.2 to 2.2", function () {
|
||||
expect(cmp("2.2", "2.2")).to.equal(0);
|
||||
expect(cmp("2.2", "2.2")).toBe(0);
|
||||
});
|
||||
|
||||
it("should be return 1 when comparing 1.1 to 1.0", function () {
|
||||
expect(cmp("1.1", "1.0")).to.equal(1);
|
||||
expect(cmp("1.1", "1.0")).toBe(1);
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,4 @@
|
||||
/* eslint no-multi-spaces: 0 */
|
||||
const expect = require("chai").expect;
|
||||
|
||||
describe("Functions module currentweather", function () {
|
||||
// Fake for use by currentweather.js
|
||||
Module = {};
|
||||
@ -10,14 +8,14 @@ describe("Functions module currentweather", function () {
|
||||
Module.definitions[name] = moduleDefinition;
|
||||
};
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
require("../../../modules/default/currentweather/currentweather.js");
|
||||
Module.definitions.currentweather.config = {};
|
||||
});
|
||||
|
||||
describe("roundValue", function () {
|
||||
describe("this.config.roundTemp is true", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
Module.definitions.currentweather.config.roundTemp = true;
|
||||
});
|
||||
|
||||
@ -35,13 +33,13 @@ describe("Functions module currentweather", function () {
|
||||
|
||||
values.forEach((value) => {
|
||||
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
||||
expect(Module.definitions.currentweather.roundValue(value[0])).to.equal(value[1]);
|
||||
expect(Module.definitions.currentweather.roundValue(value[0])).toBe(value[1]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("this.config.roundTemp is false", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
Module.definitions.currentweather.config.roundTemp = false;
|
||||
});
|
||||
|
||||
@ -60,7 +58,7 @@ describe("Functions module currentweather", function () {
|
||||
|
||||
values.forEach((value) => {
|
||||
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
||||
expect(Module.definitions.currentweather.roundValue(value[0])).to.equal(value[1]);
|
||||
expect(Module.definitions.currentweather.roundValue(value[0])).toBe(value[1]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,3 @@
|
||||
const expect = require("chai").expect;
|
||||
|
||||
describe("Functions into modules/default/newsfeed/newsfeed.js", function () {
|
||||
// Fake for use by newsletter.js
|
||||
Module = {};
|
||||
@ -8,8 +6,10 @@ describe("Functions into modules/default/newsfeed/newsfeed.js", function () {
|
||||
Module.definitions[name] = moduleDefinition;
|
||||
};
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
// load newsfeed.js
|
||||
require("../../../modules/default/newsfeed/newsfeed.js");
|
||||
});
|
||||
|
||||
test.skip("skip", () => {});
|
||||
});
|
||||
|
@ -1,10 +1,9 @@
|
||||
/* eslint no-multi-spaces: 0 */
|
||||
const expect = require("chai").expect;
|
||||
const moment = require("moment-timezone");
|
||||
const data = require("../../configs/data/weatherforecast_data.json");
|
||||
|
||||
describe("Functions module weatherforecast", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
Module = {};
|
||||
config = {};
|
||||
Module.definitions = {};
|
||||
@ -17,7 +16,7 @@ describe("Functions module weatherforecast", function () {
|
||||
|
||||
describe("roundValue", function () {
|
||||
describe("this.config.roundTemp is true", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
Module.definitions.weatherforecast.config.roundTemp = true;
|
||||
});
|
||||
|
||||
@ -35,13 +34,13 @@ describe("Functions module weatherforecast", function () {
|
||||
|
||||
values.forEach((value) => {
|
||||
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
||||
expect(Module.definitions.weatherforecast.roundValue(value[0])).to.equal(value[1]);
|
||||
expect(Module.definitions.weatherforecast.roundValue(value[0])).toBe(value[1]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("this.config.roundTemp is false", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
Module.definitions.weatherforecast.config.roundTemp = false;
|
||||
});
|
||||
|
||||
@ -60,7 +59,7 @@ describe("Functions module weatherforecast", function () {
|
||||
|
||||
values.forEach((value) => {
|
||||
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
||||
expect(Module.definitions.weatherforecast.roundValue(value[0])).to.equal(value[1]);
|
||||
expect(Module.definitions.weatherforecast.roundValue(value[0])).toBe(value[1]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -73,7 +72,7 @@ describe("Functions module weatherforecast", function () {
|
||||
|
||||
let originalLocale;
|
||||
let originalTimeZone;
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
originalLocale = moment.locale();
|
||||
originalTimeZone = moment.tz.guess();
|
||||
moment.locale("hi");
|
||||
@ -81,7 +80,7 @@ describe("Functions module weatherforecast", function () {
|
||||
});
|
||||
|
||||
describe("forecastIcons sunset specified", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
Module.definitions.weatherforecast.Log = {};
|
||||
Module.definitions.weatherforecast.forecast = [];
|
||||
Module.definitions.weatherforecast.show = Module.definitions.weatherforecast.updateDom = function () {};
|
||||
@ -89,27 +88,27 @@ describe("Functions module weatherforecast", function () {
|
||||
});
|
||||
|
||||
it(`returns correct icons with sunset time`, function () {
|
||||
Module.definitions.weatherforecast.processWeather(data.withSunset);
|
||||
Module.definitions.weatherforecast.processWeather(data.withSunset, moment);
|
||||
let forecastData = Module.definitions.weatherforecast.forecast;
|
||||
expect(forecastData.length).to.equal(4);
|
||||
expect(forecastData[2].icon).to.equal("wi-rain");
|
||||
expect(forecastData.length).toBe(4);
|
||||
expect(forecastData[2].icon).toBe("wi-rain");
|
||||
});
|
||||
});
|
||||
|
||||
describe("forecastIcons sunset not specified", function () {
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
Module.definitions.weatherforecast.forecast = [];
|
||||
});
|
||||
|
||||
it(`returns correct icons with out sunset time`, function () {
|
||||
Module.definitions.weatherforecast.processWeather(data.withoutSunset);
|
||||
Module.definitions.weatherforecast.processWeather(data.withoutSunset, moment);
|
||||
let forecastData = Module.definitions.weatherforecast.forecast;
|
||||
expect(forecastData.length).to.equal(4);
|
||||
expect(forecastData[2].icon).to.equal("wi-rain");
|
||||
expect(forecastData.length).toBe(4);
|
||||
expect(forecastData[2].icon).toBe("wi-rain");
|
||||
});
|
||||
});
|
||||
|
||||
after(function () {
|
||||
afterAll(function () {
|
||||
moment.locale(originalLocale);
|
||||
moment.tz.setDefault(originalTimeZone);
|
||||
});
|
||||
|
@ -1,39 +1,31 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const expect = require("chai").expect;
|
||||
const vm = require("vm");
|
||||
|
||||
const basedir = path.join(__dirname, "../../..");
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
const fileName = "js/app.js";
|
||||
const filePath = path.join(basedir, fileName);
|
||||
const code = fs.readFileSync(filePath);
|
||||
|
||||
this.sandbox = {
|
||||
sandbox = {
|
||||
module: {},
|
||||
__dirname: path.dirname(filePath),
|
||||
global: {},
|
||||
console: {
|
||||
log: function () {
|
||||
/*console.log("console.log(", arguments, ")");*/
|
||||
}
|
||||
},
|
||||
process: {
|
||||
on: function () {
|
||||
/*console.log("process.on called with: ", arguments);*/
|
||||
},
|
||||
on: function () {},
|
||||
env: {}
|
||||
}
|
||||
};
|
||||
|
||||
this.sandbox.require = function (filename) {
|
||||
sandbox.require = function (filename) {
|
||||
// This modifies the global slightly,
|
||||
// but supplies vm with essential code
|
||||
return require(filename);
|
||||
};
|
||||
|
||||
vm.runInNewContext(code, this.sandbox, fileName);
|
||||
vm.runInNewContext(code, sandbox, fileName);
|
||||
});
|
||||
|
||||
describe("Default modules set in modules/default/defaultmodules.js", function () {
|
||||
@ -41,7 +33,7 @@ describe("Default modules set in modules/default/defaultmodules.js", function ()
|
||||
|
||||
for (const defaultModule of expectedDefaultModules) {
|
||||
it(`contains a folder for modules/default/${defaultModule}"`, function () {
|
||||
expect(fs.existsSync(path.join(this.sandbox.global.root_path, "modules/default", defaultModule))).to.equal(true);
|
||||
expect(fs.existsSync(path.join(sandbox.global.root_path, "modules/default", defaultModule))).toBe(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,43 +1,31 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const expect = require("chai").expect;
|
||||
const vm = require("vm");
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
const basedir = path.join(__dirname, "../../..");
|
||||
|
||||
const fileName = "js/app.js";
|
||||
const filePath = path.join(basedir, fileName);
|
||||
const code = fs.readFileSync(filePath);
|
||||
|
||||
this.sandbox = {
|
||||
sandbox = {
|
||||
module: {},
|
||||
__dirname: path.dirname(filePath),
|
||||
global: {},
|
||||
console: {
|
||||
log: function () {
|
||||
/*console.log("console.log(", arguments, ")");*/
|
||||
}
|
||||
},
|
||||
process: {
|
||||
on: function () {
|
||||
/*console.log("process.on called with: ", arguments);*/
|
||||
},
|
||||
on: function () {},
|
||||
env: {}
|
||||
}
|
||||
};
|
||||
|
||||
this.sandbox.require = function (filename) {
|
||||
sandbox.require = function (filename) {
|
||||
// This modifies the global slightly,
|
||||
// but supplies vm with essential code
|
||||
return require(filename);
|
||||
};
|
||||
|
||||
vm.runInNewContext(code, this.sandbox, fileName);
|
||||
});
|
||||
|
||||
after(function () {
|
||||
//console.log(global);
|
||||
vm.runInNewContext(code, sandbox, fileName);
|
||||
});
|
||||
|
||||
describe("'global.root_path' set in js/app.js", function () {
|
||||
@ -45,20 +33,20 @@ describe("'global.root_path' set in js/app.js", function () {
|
||||
|
||||
expectedSubPaths.forEach((subpath) => {
|
||||
it(`contains a file/folder "${subpath}"`, function () {
|
||||
expect(fs.existsSync(path.join(this.sandbox.global.root_path, subpath))).to.equal(true);
|
||||
expect(fs.existsSync(path.join(sandbox.global.root_path, subpath))).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("should not modify global.root_path for testing", function () {
|
||||
expect(global.root_path).to.equal(undefined);
|
||||
expect(global.root_path).toBe(undefined);
|
||||
});
|
||||
|
||||
it("should not modify global.version for testing", function () {
|
||||
expect(global.version).to.equal(undefined);
|
||||
expect(global.version).toBe(undefined);
|
||||
});
|
||||
|
||||
it("should expect the global.version equals package.json file", function () {
|
||||
const versionPackage = JSON.parse(fs.readFileSync("package.json", "utf8")).version;
|
||||
expect(this.sandbox.global.version).to.equal(versionPackage);
|
||||
expect(sandbox.global.version).toBe(versionPackage);
|
||||
});
|
||||
});
|
||||
|
1
tests/unit/setup_unit.js
Normal file
1
tests/unit/setup_unit.js
Normal file
@ -0,0 +1 @@
|
||||
console.log = () => {};
|
Loading…
x
Reference in New Issue
Block a user