From 8e76cdcb57a69de33ceb0dd1482c0300b8c4a591 Mon Sep 17 00:00:00 2001 From: rejas Date: Sat, 17 Apr 2021 12:44:47 +0200 Subject: [PATCH] Revert "Remove some tests to see if it still errors" This reverts commit 0abebc1e3274dff10de5ac74f23d9ca6dd76aec3. --- tests/e2e/modules/alert_spec.js | 4 + tests/e2e/modules/weather_spec.js | 16 +++ tests/e2e/modules_display_spec.js | 41 +++++++ tests/unit/classes/class_spec.js | 109 +++++++++++++++++++ tests/unit/functions/weatherforecast_spec.js | 51 +++++++++ 5 files changed, 221 insertions(+) create mode 100644 tests/e2e/modules_display_spec.js create mode 100644 tests/unit/classes/class_spec.js diff --git a/tests/e2e/modules/alert_spec.js b/tests/e2e/modules/alert_spec.js index 750559a5..515001bf 100644 --- a/tests/e2e/modules/alert_spec.js +++ b/tests/e2e/modules/alert_spec.js @@ -29,5 +29,9 @@ describe("Alert module", function () { // Set config sample for use in test 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); + }); }); }); diff --git a/tests/e2e/modules/weather_spec.js b/tests/e2e/modules/weather_spec.js index d2fe4ba1..70c88512 100644 --- a/tests/e2e/modules/weather_spec.js +++ b/tests/e2e/modules/weather_spec.js @@ -257,6 +257,22 @@ describe("Weather module", function () { before(function () { 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 () { diff --git a/tests/e2e/modules_display_spec.js b/tests/e2e/modules_display_spec.js new file mode 100644 index 00000000..3dfcf26f --- /dev/null +++ b/tests/e2e/modules_display_spec.js @@ -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); + }); + }); +}); diff --git a/tests/unit/classes/class_spec.js b/tests/unit/classes/class_spec.js new file mode 100644 index 00000000..b1af5c67 --- /dev/null +++ b/tests/unit/classes/class_spec.js @@ -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( + `\ +