mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
snapshot
This commit is contained in:
parent
60f8de282d
commit
54b04962a8
1
.github/workflows/node-ci.js.yml
vendored
1
.github/workflows/node-ci.js.yml
vendored
@ -26,6 +26,7 @@ jobs:
|
|||||||
Xvfb :99 -screen 0 1024x768x16 &
|
Xvfb :99 -screen 0 1024x768x16 &
|
||||||
export DISPLAY=:99
|
export DISPLAY=:99
|
||||||
npm install
|
npm install
|
||||||
|
touch css/custom.css
|
||||||
npm run test:prettier
|
npm run test:prettier
|
||||||
npm run test:js
|
npm run test:js
|
||||||
npm run test:css
|
npm run test:css
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
const jsdom = require("jsdom");
|
||||||
|
|
||||||
exports.startApplication = function (configFilename, exec) {
|
exports.startApplication = function (configFilename, exec) {
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
// Set config sample for use in test
|
// Set config sample for use in test
|
||||||
@ -14,3 +16,12 @@ exports.stopApplication = function (app) {
|
|||||||
app.stop();
|
app.stop();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.getDocument = function (url, callback) {
|
||||||
|
jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => {
|
||||||
|
dom.window.onload = function () {
|
||||||
|
global.document = dom.window.document;
|
||||||
|
callback();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
function myError(err) {
|
function myError(err) {
|
||||||
//console.dir(err);
|
if (err.includes("ECONNREFUSED")) {
|
||||||
if (err.includes("ECONNREFUSED")) { jest.fn() } else { console.dir(err) };
|
jest.fn();
|
||||||
};
|
} else {
|
||||||
|
console.dir(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
global.console = {
|
global.console = {
|
||||||
log: jest.fn(),
|
log: jest.fn(),
|
||||||
dir: console.dir,
|
dir: console.dir,
|
||||||
error: myError,
|
error: myError,
|
||||||
// error: console.error,
|
|
||||||
warn: console.warn,
|
warn: console.warn,
|
||||||
info: jest.fn(),
|
info: jest.fn(),
|
||||||
debug: console.debug
|
debug: console.debug
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
const jsdom = require("jsdom");
|
|
||||||
// const fetch = require("node-fetch");
|
|
||||||
const helpers = require("./global-setup");
|
|
||||||
let app = null;
|
|
||||||
|
|
||||||
describe("Display of modules", function () {
|
|
||||||
beforeAll(function () {
|
|
||||||
// todo: require is not defined ...
|
|
||||||
// jest.mock("logger");
|
|
||||||
app = helpers.startApplication("tests/configs/modules/display.js");
|
|
||||||
// app = helpers.startApplication("config/config.js");
|
|
||||||
});
|
|
||||||
afterAll(function () {
|
|
||||||
helpers.stopApplication(app);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should show the test header", function (done) {
|
|
||||||
jsdom.JSDOM.fromURL("http://localhost:8080", { resources: "usable", runScripts: "dangerously" }).then((dom) => {
|
|
||||||
// console.log(dom.serialize());
|
|
||||||
dom.window.onload = function () {
|
|
||||||
const doc = dom.window.document;
|
|
||||||
let elem = doc.querySelector("title");
|
|
||||||
expect(elem).not.toBe(null);
|
|
||||||
expect(elem.textContent).toBe("MagicMirror²");
|
|
||||||
/*
|
|
||||||
const children = doc.body.getElementsByTagName("*");
|
|
||||||
for (var i = 0, length = children.length; i < length; i++) {
|
|
||||||
child = children[i];
|
|
||||||
if (child.id !== "") console.dir(child.id);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
elem = doc.querySelector("#module_0_helloworld .module-header");
|
|
||||||
expect(elem).not.toBe(null);
|
|
||||||
expect(elem.textContent).toBe("test_header");
|
|
||||||
//result ist leider lowercase wegen fehlendem css, siehe https://stackoverflow.com/questions/10318330/how-do-you-add-stylesheets-to-jsdom
|
|
||||||
elem = doc.querySelector("#module_1_helloworld .module-header");
|
|
||||||
expect(elem).not.toBe(null);
|
|
||||||
expect(elem.textContent).toBe("undefined");
|
|
||||||
|
|
||||||
//dom.window.close();
|
|
||||||
done();
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
25
tests/e2e/modules_display_spec.js
Normal file
25
tests/e2e/modules_display_spec.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
const helpers = require("./global-setup");
|
||||||
|
let app = null;
|
||||||
|
|
||||||
|
describe("Display of modules", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
app = helpers.startApplication("tests/configs/modules/display.js");
|
||||||
|
helpers.getDocument("http://localhost:8080", done);
|
||||||
|
});
|
||||||
|
afterAll(function () {
|
||||||
|
helpers.stopApplication(app);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show the test header", function () {
|
||||||
|
elem = document.querySelector("#module_0_helloworld .module-header");
|
||||||
|
expect(elem).not.toBe(null);
|
||||||
|
expect(elem.textContent).toBe("test_header");
|
||||||
|
//result ist leider lowercase wegen fehlendem css, siehe https://stackoverflow.com/questions/10318330/how-do-you-add-stylesheets-to-jsdom
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show no header if no header text is specified", function () {
|
||||||
|
elem = document.querySelector("#module_1_helloworld .module-header");
|
||||||
|
expect(elem).not.toBe(null);
|
||||||
|
expect(elem.textContent).toBe("undefined");
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user