Add test setup for custom calendar configuration

This commit is contained in:
rejas 2020-07-18 13:57:48 +02:00
parent 530c5d416a
commit a391445e5f
3 changed files with 57 additions and 3 deletions

View File

@ -207,7 +207,7 @@ Module.register("calendar", {
eventWrapper.style.cssText = "color:" + this.colorForUrl(event.url);
}
eventWrapper.className = "normal";
eventWrapper.className = "normal event";
if (this.config.displaySymbol) {
var symbolWrapper = document.createElement("td");

View File

@ -0,0 +1,38 @@
/* Magic Mirror Test config custom calendar
*
* MIT Licensed.
*/
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
language: "en",
timeFormat: 12,
units: "metric",
electronOptions: {
webPreferences: {
nodeIntegration: true
}
},
modules: [
{
module: "calendar",
position: "bottom_bar",
config: {
calendars: [
{
maximumEntries: 3,
maximumNumberOfDays: 10000,
url: "http://localhost:8080/tests/configs/data/calendar_test.ics"
}
]
}
}
]
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}

View File

@ -1,5 +1,6 @@
const helpers = require("../global-setup");
const serverBasicAuth = require("../../servers/basic-auth.js");
const expect = require("chai").expect;
const describe = global.describe;
const it = global.it;
@ -31,8 +32,23 @@ describe("Calendar module", function () {
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/default.js";
});
it("Should return TestEvents", function () {
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
it("Should show the default maximumEntries of 10", async () => {
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
const events = await app.client.$$(".calendar .event");
return expect(events.length).equals(10);
});
});
describe("Custom configuration", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/custom.js";
});
it("Should show the custom maximumEntries of 3", async () => {
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
const events = await app.client.$$(".calendar .event");
return expect(events.length).equals(3);
});
});