Use es6 notation in tests

This commit is contained in:
rejas 2021-04-08 21:12:56 +02:00
parent 6eba8d681c
commit d736dd92be
23 changed files with 36 additions and 53 deletions

View File

@ -1,5 +1,6 @@
/* Magic Mirror Test config custom calendar
*
* By Rejas
* MIT Licensed.
*/
let config = {

View File

@ -1,9 +1,7 @@
/* Magic Mirror Test config for default clock module
* Language es for showWeek feature
*
* By Rodrigo Ramírez Norambuena
* https://rodrigoramirez.com
*
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed.
*/
let config = {

View File

@ -1,5 +1,6 @@
/* Magic Mirror Test config for display setters module using the helloworld module
*
* By Rejas
* MIT Licensed.
*/
let config = {
@ -37,6 +38,7 @@ let config = {
}
]
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;

View File

@ -1,6 +1,4 @@
/* Magic Mirror Test config for position setters module
*
* For this case is using helloworld module
/* Magic Mirror Test config for position setters module using the helloworld module
*
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed.
@ -36,6 +34,7 @@ let config = {
return modules;
})()
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;

View File

@ -1,10 +1,8 @@
/* Magic Mirror Test config current weather compliments
*
* By rejas https://github.com/rejas
*
* MIT Licensed.
*/
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],

View File

@ -1,10 +1,8 @@
/* Magic Mirror Test config default weather
*
* By fewieden https://github.com/fewieden
*
* MIT Licensed.
*/
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],

View File

@ -1,10 +1,8 @@
/* Magic Mirror Test config default weather
*
* By fewieden https://github.com/fewieden
*
* MIT Licensed.
*/
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],

View File

@ -1,10 +1,8 @@
/* Magic Mirror Test config default weather
*
* By fewieden https://github.com/fewieden
*
* MIT Licensed.
*/
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],

View File

@ -1,10 +1,8 @@
/* Magic Mirror Test config default weather
*
* By fewieden https://github.com/fewieden
*
* MIT Licensed.
*/
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],

View File

@ -1,10 +1,8 @@
/* Magic Mirror Test config default weather
*
* By fewieden https://github.com/fewieden
*
* MIT Licensed.
*/
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],

View File

@ -12,7 +12,7 @@ describe("Development console tests", function () {
/* eslint-disable */
helpers.setupTimeout(this);
var app = null;
let app = null;
before(function () {
// Set config sample for use in test

View File

@ -10,7 +10,7 @@ const afterEach = global.afterEach;
describe("Electron app environment", function () {
helpers.setupTimeout(this);
var app = null;
let app = null;
before(function () {
// Set config sample for use in test

View File

@ -1,13 +1,9 @@
/*
* Magic Mirror
*
* Global Setup Test Suite
* Magic Mirror Global Setup Test Suite
*
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed.
*
*/
const Application = require("spectron").Application;
const assert = require("assert");
const chai = require("chai");

View File

@ -10,7 +10,7 @@ const afterEach = global.afterEach;
describe("ipWhitelist directive configuration", function () {
helpers.setupTimeout(this);
var app = null;
let app = null;
beforeEach(function () {
return helpers
@ -31,6 +31,7 @@ describe("ipWhitelist directive configuration", 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);
@ -44,6 +45,7 @@ describe("ipWhitelist directive configuration", 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);

View File

@ -6,7 +6,7 @@ const it = global.it;
describe("Display of modules", function () {
helpers.setupTimeout(this);
var app = null;
let app = null;
beforeEach(function () {
return helpers

View File

@ -6,7 +6,7 @@ const it = global.it;
describe("Position of modules", function () {
helpers.setupTimeout(this);
var app = null;
let app = null;
describe("Using helloworld", function () {
after(function () {
@ -25,14 +25,11 @@ describe("Position of modules", function () {
});
});
var positions = ["top_bar", "top_left", "top_center", "top_right", "upper_third", "middle_center", "lower_third", "bottom_left", "bottom_center", "bottom_right", "bottom_bar", "fullscreen_above", "fullscreen_below"];
const positions = ["top_bar", "top_left", "top_center", "top_right", "upper_third", "middle_center", "lower_third", "bottom_left", "bottom_center", "bottom_right", "bottom_bar", "fullscreen_above", "fullscreen_below"];
var position;
var className;
for (var idx in positions) {
position = positions[idx];
className = position.replace("_", ".");
it("show text in " + position, function () {
for (const position of positions) {
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);
});

View File

@ -10,7 +10,7 @@ const afterEach = global.afterEach;
describe("port directive configuration", function () {
helpers.setupTimeout(this);
var app = null;
let app = null;
beforeEach(function () {
return helpers

View File

@ -10,7 +10,7 @@ const after = global.after;
describe("Vendors", function () {
helpers.setupTimeout(this);
var app = null;
let app = null;
before(function () {
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
@ -31,7 +31,7 @@ describe("Vendors", function () {
const vendors = require(__dirname + "/../../vendor/vendor.js");
Object.keys(vendors).forEach((vendor) => {
it(`should return 200 HTTP code for vendor "${vendor}"`, function () {
var urlVendor = "http://localhost:8080/vendor/" + vendors[vendor];
const urlVendor = "http://localhost:8080/vendor/" + vendors[vendor];
fetch(urlVendor).then((res) => {
expect(res.status).to.equal(200);
});
@ -40,7 +40,7 @@ describe("Vendors", function () {
Object.keys(vendors).forEach((vendor) => {
it(`should return 404 HTTP code for vendor https://localhost/"${vendor}"`, function () {
var urlVendor = "http://localhost:8080/" + vendors[vendor];
const urlVendor = "http://localhost:8080/" + vendors[vendor];
fetch(urlVendor).then((res) => {
expect(res.status).to.equal(404);
});

View File

@ -8,7 +8,7 @@ const afterEach = global.afterEach;
describe("Check configuration without modules", function () {
helpers.setupTimeout(this);
var app = null;
let app = null;
beforeEach(function () {
return helpers

View File

@ -4,7 +4,7 @@ const colors = require("colors/safe");
describe("Utils", function () {
describe("colors", function () {
var colorsEnabled = colors.enabled;
const colorsEnabled = colors.enabled;
afterEach(function () {
colors.enabled = colorsEnabled;

View File

@ -21,7 +21,7 @@ describe("Functions module currentweather", function () {
Module.definitions.currentweather.config.roundTemp = true;
});
var values = [
const values = [
// index 0 value
// index 1 expect
[1, "1"],
@ -45,7 +45,7 @@ describe("Functions module currentweather", function () {
Module.definitions.currentweather.config.roundTemp = false;
});
var values = [
const values = [
// index 0 value
// index 1 expect
[1, "1.0"],

View File

@ -1,7 +1,7 @@
/* eslint no-multi-spaces: 0 */
const expect = require("chai").expect;
const moment = require("moment-timezone");
var data = require("../functions/weatherforecast_data.json");
const data = require("../functions/weatherforecast_data.json");
describe("Functions module weatherforecast", function () {
before(function () {
@ -21,7 +21,7 @@ describe("Functions module weatherforecast", function () {
Module.definitions.weatherforecast.config.roundTemp = true;
});
var values = [
const values = [
// index 0 value
// index 1 expect
[1, "1"],
@ -45,7 +45,7 @@ describe("Functions module weatherforecast", function () {
Module.definitions.weatherforecast.config.roundTemp = false;
});
var values = [
const values = [
// index 0 value
// index 1 expect
[1, "1.0"],
@ -71,8 +71,8 @@ describe("Functions module weatherforecast", function () {
error: function () {}
};
var originalLocale;
var originalTimeZone;
let originalLocale;
let originalTimeZone;
before(function () {
originalLocale = moment.locale();
originalTimeZone = moment.tz.guess();

View File

@ -4,11 +4,11 @@ const expect = require("chai").expect;
const vm = require("vm");
before(function () {
var basedir = path.join(__dirname, "../../..");
const basedir = path.join(__dirname, "../../..");
var fileName = "js/app.js";
var filePath = path.join(basedir, fileName);
var code = fs.readFileSync(filePath);
const fileName = "js/app.js";
const filePath = path.join(basedir, fileName);
const code = fs.readFileSync(filePath);
this.sandbox = {
module: {},
@ -41,7 +41,7 @@ after(function () {
});
describe("'global.root_path' set in js/app.js", function () {
var expectedSubPaths = ["modules", "serveronly", "js", "js/app.js", "js/main.js", "js/electron.js", "config"];
const expectedSubPaths = ["modules", "serveronly", "js", "js/app.js", "js/main.js", "js/electron.js", "config"];
expectedSubPaths.forEach((subpath) => {
it(`contains a file/folder "${subpath}"`, function () {