mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Symbols provided in customEvents don't get the "fas fa-fw fa-" prefix, which according to the docs they should. This fixes that. Hello and thank you for wanting to contribute to the MagicMirror² project **Please make sure that you have followed these 4 rules before submitting your Pull Request:** > 1. Base your pull requests against the `develop` branch. > > 2. Include these infos in the description: > > - Does the pull request solve a **related** issue? > - If so, can you reference the issue like this `Fixes #<issue_number>`? > - What does the pull request accomplish? Use a list if needed. > - If it includes major visual changes please add screenshots. > > 3. Please run `npm run lint:prettier` before submitting so that > style issues are fixed. > > 4. Don't forget to add an entry about your changes to > the CHANGELOG.md file. **Note**: Sometimes the development moves very fast. It is highly recommended that you update your branch of `develop` before creating a pull request to send us your changes. This makes everyone's lives easier (including yours) and helps us out on the development team. Thanks again and have a nice day! Co-authored-by: veeck <michael@veeck.de>
165 lines
4.7 KiB
JavaScript
165 lines
4.7 KiB
JavaScript
const helpers = require("../helpers/global-setup");
|
|
const serverBasicAuth = require("../helpers/basic-auth.js");
|
|
|
|
describe("Calendar module", () => {
|
|
/**
|
|
* @param {string} element css selector
|
|
* @param {string} result expected number
|
|
* @param {string} not reverse result
|
|
*/
|
|
const testElementLength = async (element, result, not) => {
|
|
const elem = await helpers.waitForAllElements(element);
|
|
expect(elem).not.toBe(null);
|
|
if (not === "not") {
|
|
expect(elem.length).not.toBe(result);
|
|
} else {
|
|
expect(elem.length).toBe(result);
|
|
}
|
|
};
|
|
|
|
const testTextContain = async (element, text) => {
|
|
const elem = await helpers.waitForElement(element, "undefinedLoading");
|
|
expect(elem).not.toBe(null);
|
|
expect(elem.textContent).toContain(text);
|
|
};
|
|
|
|
afterAll(async () => {
|
|
await helpers.stopApplication();
|
|
});
|
|
|
|
describe("Default configuration", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/default.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it("should show the default maximumEntries of 10", async () => {
|
|
await testElementLength(".calendar .event", 10);
|
|
});
|
|
|
|
it("should show the default calendar symbol in each event", async () => {
|
|
await testElementLength(".calendar .event .fa-calendar-alt", 0, "not");
|
|
});
|
|
});
|
|
|
|
describe("Custom configuration", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/custom.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it("should show the custom maximumEntries of 5", async () => {
|
|
await testElementLength(".calendar .event", 5);
|
|
});
|
|
|
|
it("should show the custom calendar symbol in four events", async () => {
|
|
await testElementLength(".calendar .event .fa-birthday-cake", 4);
|
|
});
|
|
|
|
it("should show a customEvent calendar symbol in one event", async () => {
|
|
await testElementLength(".calendar .event .fa-dice", 1);
|
|
});
|
|
|
|
it("should show two custom icons for repeating events", async () => {
|
|
await testElementLength(".calendar .event .fa-undo", 2);
|
|
});
|
|
|
|
it("should show two custom icons for day events", async () => {
|
|
await testElementLength(".calendar .event .fa-calendar-day", 2);
|
|
});
|
|
});
|
|
|
|
describe("Recurring event", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/recurring.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it("should show the recurring birthday event 6 times", async () => {
|
|
await testElementLength(".calendar .event", 6);
|
|
});
|
|
});
|
|
|
|
process.setMaxListeners(0);
|
|
for (let i = -12; i < 12; i++) {
|
|
describe("Recurring event per timezone", () => {
|
|
beforeAll(async () => {
|
|
Date.prototype.getTimezoneOffset = () => {
|
|
return i * 60;
|
|
};
|
|
await helpers.startApplication("tests/configs/modules/calendar/recurring.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it('should contain text "Mar 25th" in timezone UTC ' + -i, async () => {
|
|
await testTextContain(".calendar", "Mar 25th");
|
|
});
|
|
});
|
|
}
|
|
|
|
describe("Changed port", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/changed-port.js");
|
|
serverBasicAuth.listen(8010);
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await serverBasicAuth.close();
|
|
});
|
|
|
|
it("should return TestEvents", async () => {
|
|
await testElementLength(".calendar .event", 0, "not");
|
|
});
|
|
});
|
|
|
|
describe("Basic auth", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/basic-auth.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it("should return TestEvents", async () => {
|
|
await testElementLength(".calendar .event", 0, "not");
|
|
});
|
|
});
|
|
|
|
describe("Basic auth by default", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/auth-default.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it("should return TestEvents", async () => {
|
|
await testElementLength(".calendar .event", 0, "not");
|
|
});
|
|
});
|
|
|
|
describe("Basic auth backward compatibility configuration: DEPRECATED", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/old-basic-auth.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it("should return TestEvents", async () => {
|
|
await testElementLength(".calendar .event", 0, "not");
|
|
});
|
|
});
|
|
|
|
describe("Fail Basic auth", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/fail-basic-auth.js");
|
|
serverBasicAuth.listen(8020);
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await serverBasicAuth.close();
|
|
});
|
|
|
|
it("should show Unauthorized error", async () => {
|
|
await testTextContain(".calendar", "Error in the calendar module. Authorization failed");
|
|
});
|
|
});
|
|
});
|