MagicMirror/tests/e2e/modules/newsfeed_spec.js

64 lines
2.0 KiB
JavaScript
Raw Normal View History

2021-09-26 00:06:06 +02:00
const helpers = require("../global-setup");
describe("Newsfeed module", function () {
afterAll(function () {
helpers.stopApplication();
});
describe("Default configuration", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/newsfeed/default.js");
helpers.getDocument(done, 3000);
});
it("should show the newsfeed title", function () {
const elem = document.querySelector(".newsfeed .newsfeed-source");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Rodrigo Ramirez Blog");
});
it("should show the newsfeed article", function () {
const elem = document.querySelector(".newsfeed .newsfeed-title");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("QPanel");
});
2021-09-26 21:58:59 +02:00
it("should NOT show the newsfeed description", () => {
2021-09-26 00:06:06 +02:00
const elem = document.querySelector(".newsfeed .newsfeed-desc");
expect(elem).toBe(null);
});
});
describe("Custom configuration", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/newsfeed/prohibited_words.js");
helpers.getDocument(done, 3000);
});
it("should not show articles with prohibited words", function () {
const elem = document.querySelector(".newsfeed .newsfeed-title");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Problema VirtualBox");
});
2021-09-26 21:58:59 +02:00
it("should show the newsfeed description", () => {
2021-09-26 00:06:06 +02:00
const elem = document.querySelector(".newsfeed .newsfeed-desc");
expect(elem).not.toBe(null);
expect(elem.textContent.length).not.toBe(0);
});
});
describe("Invalid configuration", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/newsfeed/incorrect_url.js");
helpers.getDocument(done, 3000);
});
it("should show malformed url warning", function () {
const elem = document.querySelector(".newsfeed .small");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Error in the Newsfeed module. Malformed url.");
});
});
});