mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-22 13:09:26 +00:00
snapshot
This commit is contained in:
@@ -1,9 +1,14 @@
|
|||||||
|
function myError(err) {
|
||||||
|
//console.dir(err);
|
||||||
|
if (err.includes("ECONNREFUSED")) { jest.fn() } else { console.dir(err) };
|
||||||
|
};
|
||||||
|
|
||||||
global.console = {
|
global.console = {
|
||||||
log: console.log,
|
log: jest.fn(),
|
||||||
dir: console.dir,
|
dir: console.dir,
|
||||||
// error: jest.fn(),
|
error: myError,
|
||||||
error: console.error,
|
// error: console.error,
|
||||||
warn: console.warn,
|
warn: console.warn,
|
||||||
info: console.info,
|
info: jest.fn(),
|
||||||
debug: console.debug
|
debug: console.debug
|
||||||
};
|
};
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
const jsdom = require("jsdom");
|
const jsdom = require("jsdom");
|
||||||
const fetch = require("node-fetch");
|
// const fetch = require("node-fetch");
|
||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
let app = null;
|
let app = null;
|
||||||
|
|
||||||
describe("test headers", function () {
|
describe("Display of modules", function () {
|
||||||
beforeAll(function () {
|
beforeAll(function () {
|
||||||
// todo: require is not defined ...
|
// todo: require is not defined ...
|
||||||
// jest.mock("logger");
|
// jest.mock("logger");
|
||||||
@@ -14,24 +14,32 @@ describe("test headers", function () {
|
|||||||
helpers.stopApplication(app);
|
helpers.stopApplication(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("test", function (done) {
|
it("should show the test header", function (done) {
|
||||||
jsdom.JSDOM.fromURL("http://localhost:8080", { resources: "usable", runScripts: "dangerously" }).then((dom) => {
|
jsdom.JSDOM.fromURL("http://localhost:8080", { resources: "usable", runScripts: "dangerously" }).then((dom) => {
|
||||||
// console.log(dom.serialize());
|
// console.log(dom.serialize());
|
||||||
dom.window.onload = function () {
|
dom.window.onload = function () {
|
||||||
const doc = dom.window.document;
|
const doc = dom.window.document;
|
||||||
console.log(doc.querySelector("title").textContent);
|
let elem = doc.querySelector("title");
|
||||||
|
expect(elem).not.toBe(null);
|
||||||
|
expect(elem.textContent).toBe("MagicMirror²");
|
||||||
|
/*
|
||||||
const children = doc.body.getElementsByTagName("*");
|
const children = doc.body.getElementsByTagName("*");
|
||||||
for (var i = 0, length = children.length; i < length; i++) {
|
for (var i = 0, length = children.length; i < length; i++) {
|
||||||
child = children[i];
|
child = children[i];
|
||||||
if (child.id !== "") console.dir(child.id);
|
if (child.id !== "") console.dir(child.id);
|
||||||
}
|
}
|
||||||
console.log(doc.querySelector("#module_0_helloworld .module-header").textContent);
|
*/
|
||||||
// result ist leider lowercase wegen fehlendem css, siehe https://stackoverflow.com/questions/10318330/how-do-you-add-stylesheets-to-jsdom
|
elem = doc.querySelector("#module_0_helloworld .module-header");
|
||||||
// const elem = doc.getElementById("module_0_helloworld");
|
expect(elem).not.toBe(null);
|
||||||
// console.dir(elem);
|
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();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
// done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user