mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Revert "Remove some tests to see if it still errors"
This reverts commit 0abebc1e3274dff10de5ac74f23d9ca6dd76aec3.
This commit is contained in:
parent
5eb66106b9
commit
8e76cdcb57
@ -29,5 +29,9 @@ describe("Alert module", function () {
|
|||||||
// Set config sample for use in test
|
// Set config sample for use in test
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/alert/default.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/alert/default.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should show the welcome message", function () {
|
||||||
|
return app.client.waitUntilTextExists(".ns-box .ns-box-inner .light.bright.small", "Welcome, start was successful!", 10000);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -257,6 +257,22 @@ describe("Weather module", function () {
|
|||||||
before(function () {
|
before(function () {
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/forecastweather_options.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/forecastweather_options.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should render custom table class", async function () {
|
||||||
|
const weather = generateWeatherForecast();
|
||||||
|
await setup({ template, data: weather });
|
||||||
|
|
||||||
|
await getElement(".weather table.myTableClass");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should render colored rows", async function () {
|
||||||
|
const weather = generateWeatherForecast();
|
||||||
|
await setup({ template, data: weather });
|
||||||
|
|
||||||
|
const rows = await app.client.$$(".weather table.myTableClass tr.colored");
|
||||||
|
|
||||||
|
expect(rows.length).to.be.equal(5);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Forecast weather units", function () {
|
describe("Forecast weather units", function () {
|
||||||
|
41
tests/e2e/modules_display_spec.js
Normal file
41
tests/e2e/modules_display_spec.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
const helpers = require("./global-setup");
|
||||||
|
|
||||||
|
const describe = global.describe;
|
||||||
|
const it = global.it;
|
||||||
|
|
||||||
|
describe("Display of modules", function () {
|
||||||
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
|
var app = null;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
return helpers
|
||||||
|
.startApplication({
|
||||||
|
args: ["js/electron.js"]
|
||||||
|
})
|
||||||
|
.then(function (startedApp) {
|
||||||
|
app = startedApp;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function () {
|
||||||
|
return helpers.stopApplication(app);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Using helloworld", function () {
|
||||||
|
before(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");
|
||||||
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
109
tests/unit/classes/class_spec.js
Normal file
109
tests/unit/classes/class_spec.js
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
const expect = require("chai").expect;
|
||||||
|
const path = require("path");
|
||||||
|
const { JSDOM } = require("jsdom");
|
||||||
|
|
||||||
|
describe("File js/class", function () {
|
||||||
|
describe("Test function cloneObject", function () {
|
||||||
|
let clone;
|
||||||
|
let dom;
|
||||||
|
|
||||||
|
before(function (done) {
|
||||||
|
dom = new JSDOM(
|
||||||
|
`<script>var Log = {log: function() {}};</script>\
|
||||||
|
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "class.js")}">`,
|
||||||
|
{ runScripts: "dangerously", resources: "usable" }
|
||||||
|
);
|
||||||
|
dom.window.onload = function () {
|
||||||
|
const { cloneObject } = dom.window;
|
||||||
|
clone = cloneObject;
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should clone number", function () {
|
||||||
|
let expected = 1;
|
||||||
|
let obj = clone(expected);
|
||||||
|
expect(obj).to.equal(expected);
|
||||||
|
|
||||||
|
expected = 1.23;
|
||||||
|
obj = clone(expected);
|
||||||
|
expect(obj).to.equal(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should clone string", function () {
|
||||||
|
const expected = "Perfect stranger";
|
||||||
|
const obj = clone(expected);
|
||||||
|
expect(obj).to.equal(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should clone undefined", function () {
|
||||||
|
const expected = undefined;
|
||||||
|
const obj = clone(expected);
|
||||||
|
expect(obj).to.equal(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should clone null", function () {
|
||||||
|
const expected = null;
|
||||||
|
const obj = clone(expected);
|
||||||
|
expect(obj).to.equal(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should clone nested object", function () {
|
||||||
|
const expected = {
|
||||||
|
name: "fewieden",
|
||||||
|
link: "https://github.com/fewieden",
|
||||||
|
versions: ["2.0", "2.1", "2.2"],
|
||||||
|
answerForAllQuestions: 42,
|
||||||
|
properties: {
|
||||||
|
items: [{ foo: "bar" }, { lorem: "ipsum" }],
|
||||||
|
invalid: undefined,
|
||||||
|
nothing: null
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Test lockstring code", function () {
|
||||||
|
let log;
|
||||||
|
|
||||||
|
before(function () {
|
||||||
|
log = dom.window.Log.log;
|
||||||
|
dom.window.Log.log = function cmp(str) {
|
||||||
|
expect(str).to.equal("lockStrings");
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
after(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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -15,6 +15,57 @@ describe("Functions module weatherforecast", function () {
|
|||||||
Module.definitions.weatherforecast.config = {};
|
Module.definitions.weatherforecast.config = {};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("roundValue", function () {
|
||||||
|
describe("this.config.roundTemp is true", function () {
|
||||||
|
before(function () {
|
||||||
|
Module.definitions.weatherforecast.config.roundTemp = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
var values = [
|
||||||
|
// index 0 value
|
||||||
|
// index 1 expect
|
||||||
|
[1, "1"],
|
||||||
|
[1.0, "1"],
|
||||||
|
[1.02, "1"],
|
||||||
|
[10.12, "10"],
|
||||||
|
[2.0, "2"],
|
||||||
|
["2.12", "2"],
|
||||||
|
[10.1, "10"]
|
||||||
|
];
|
||||||
|
|
||||||
|
values.forEach((value) => {
|
||||||
|
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
||||||
|
expect(Module.definitions.weatherforecast.roundValue(value[0])).to.equal(value[1]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("this.config.roundTemp is false", function () {
|
||||||
|
before(function () {
|
||||||
|
Module.definitions.weatherforecast.config.roundTemp = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
var values = [
|
||||||
|
// index 0 value
|
||||||
|
// index 1 expect
|
||||||
|
[1, "1.0"],
|
||||||
|
[1.0, "1.0"],
|
||||||
|
[1.02, "1.0"],
|
||||||
|
[10.12, "10.1"],
|
||||||
|
[2.0, "2.0"],
|
||||||
|
["2.12", "2.1"],
|
||||||
|
[10.1, "10.1"],
|
||||||
|
[10.1, "10.1"]
|
||||||
|
];
|
||||||
|
|
||||||
|
values.forEach((value) => {
|
||||||
|
it(`for ${value[0]} should be return ${value[1]}`, function () {
|
||||||
|
expect(Module.definitions.weatherforecast.roundValue(value[0])).to.equal(value[1]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("forecastIcons", function () {
|
describe("forecastIcons", function () {
|
||||||
Log = {
|
Log = {
|
||||||
error: function () {}
|
error: function () {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user