mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
enable eslint jest/expect-expect and jest/no-done-callback (#3272)
follow up to https://github.com/MichMich/MagicMirror/pull/3270
This commit is contained in:
parent
7098f1e41f
commit
6ffdc7b55b
@ -27,8 +27,8 @@
|
|||||||
"import/extensions": "error",
|
"import/extensions": "error",
|
||||||
"import/newline-after-import": "error",
|
"import/newline-after-import": "error",
|
||||||
"jest/consistent-test-it": "warn",
|
"jest/consistent-test-it": "warn",
|
||||||
"jest/expect-expect": "off",
|
"jest/expect-expect": "warn",
|
||||||
"jest/no-done-callback": "off",
|
"jest/no-done-callback": "warn",
|
||||||
"jest/prefer-expect-resolves": "warn",
|
"jest/prefer-expect-resolves": "warn",
|
||||||
"jest/prefer-mock-promise-shorthand": "warn",
|
"jest/prefer-mock-promise-shorthand": "warn",
|
||||||
"jest/prefer-to-be": "warn",
|
"jest/prefer-to-be": "warn",
|
||||||
|
@ -14,7 +14,7 @@ _This release is scheduled to be released on 2024-01-01._
|
|||||||
- Added updatenotification Updater (for 3rd party modules)
|
- Added updatenotification Updater (for 3rd party modules)
|
||||||
- Added node 21 to the test matrix
|
- Added node 21 to the test matrix
|
||||||
- Added transform object to calendar:customEvents
|
- Added transform object to calendar:customEvents
|
||||||
- Added ESLint rules for jest
|
- Added ESLint rules for jest (including jest/expect-expect and jest/no-done-callback)
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ describe("AnimateCSS integration Test", () => {
|
|||||||
* move similar tests in function doTest
|
* move similar tests in function doTest
|
||||||
* @param {string} [animationIn] animation in name of AnimateCSS to test.
|
* @param {string} [animationIn] animation in name of AnimateCSS to test.
|
||||||
* @param {string} [animationOut] animation out name of AnimateCSS to test.
|
* @param {string} [animationOut] animation out name of AnimateCSS to test.
|
||||||
|
* @returns {boolean} result
|
||||||
*/
|
*/
|
||||||
const doTest = async (animationIn, animationOut) => {
|
const doTest = async (animationIn, animationOut) => {
|
||||||
await helpers.getDocument();
|
await helpers.getDocument();
|
||||||
@ -42,6 +43,7 @@ describe("AnimateCSS integration Test", () => {
|
|||||||
} else {
|
} else {
|
||||||
expect(styles._values["animation-name"]).toBeUndefined();
|
expect(styles._values["animation-name"]).toBeUndefined();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
@ -51,28 +53,28 @@ describe("AnimateCSS integration Test", () => {
|
|||||||
describe("animateIn and animateOut Test", () => {
|
describe("animateIn and animateOut Test", () => {
|
||||||
it("with flipInX and flipOutX animation", async () => {
|
it("with flipInX and flipOutX animation", async () => {
|
||||||
await helpers.startApplication(testConfigFile);
|
await helpers.startApplication(testConfigFile);
|
||||||
await doTest("flipInX", "flipOutX");
|
await expect(doTest("flipInX", "flipOutX")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("use animateOut name for animateIn (vice versa) Test", () => {
|
describe("use animateOut name for animateIn (vice versa) Test", () => {
|
||||||
it("without animation", async () => {
|
it("without animation", async () => {
|
||||||
await helpers.startApplication(testConfigFileInvertedAnimationName);
|
await helpers.startApplication(testConfigFileInvertedAnimationName);
|
||||||
await doTest();
|
await expect(doTest()).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("false Animation name test", () => {
|
describe("false Animation name test", () => {
|
||||||
it("without animation", async () => {
|
it("without animation", async () => {
|
||||||
await helpers.startApplication(testConfigFileFallbackToDefault);
|
await helpers.startApplication(testConfigFileFallbackToDefault);
|
||||||
await doTest();
|
await expect(doTest()).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("no Animation defined test", () => {
|
describe("no Animation defined test", () => {
|
||||||
it("without animation", async () => {
|
it("without animation", async () => {
|
||||||
await helpers.startApplication(testConfigByDefault);
|
await helpers.startApplication(testConfigByDefault);
|
||||||
await doTest();
|
await expect(doTest()).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -84,4 +84,5 @@ exports.testMatch = async (element, regex) => {
|
|||||||
const elem = await this.waitForElement(element);
|
const elem = await this.waitForElement(element);
|
||||||
expect(elem).not.toBeNull();
|
expect(elem).not.toBeNull();
|
||||||
expect(elem.textContent).toMatch(regex);
|
expect(elem.textContent).toMatch(regex);
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
@ -10,6 +10,7 @@ exports.getText = async (element, result) => {
|
|||||||
.replace(/(\r\n|\n|\r)/gm, "")
|
.replace(/(\r\n|\n|\r)/gm, "")
|
||||||
.replace(/[ ]+/g, " ")
|
.replace(/[ ]+/g, " ")
|
||||||
).toBe(result);
|
).toBe(result);
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.startApp = async (configFileName, additionalMockData) => {
|
exports.startApp = async (configFileName, additionalMockData) => {
|
||||||
|
@ -6,6 +6,7 @@ describe("Calendar module", () => {
|
|||||||
* @param {string} element css selector
|
* @param {string} element css selector
|
||||||
* @param {string} result expected number
|
* @param {string} result expected number
|
||||||
* @param {string} not reverse result
|
* @param {string} not reverse result
|
||||||
|
* @returns {boolean} result
|
||||||
*/
|
*/
|
||||||
const testElementLength = async (element, result, not) => {
|
const testElementLength = async (element, result, not) => {
|
||||||
const elem = await helpers.waitForAllElements(element);
|
const elem = await helpers.waitForAllElements(element);
|
||||||
@ -15,12 +16,14 @@ describe("Calendar module", () => {
|
|||||||
} else {
|
} else {
|
||||||
expect(elem).toHaveLength(result);
|
expect(elem).toHaveLength(result);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const testTextContain = async (element, text) => {
|
const testTextContain = async (element, text) => {
|
||||||
const elem = await helpers.waitForElement(element, "undefinedLoading");
|
const elem = await helpers.waitForElement(element, "undefinedLoading");
|
||||||
expect(elem).not.toBeNull();
|
expect(elem).not.toBeNull();
|
||||||
expect(elem.textContent).toContain(text);
|
expect(elem.textContent).toContain(text);
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
@ -34,11 +37,11 @@ describe("Calendar module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should show the default maximumEntries of 10", async () => {
|
it("should show the default maximumEntries of 10", async () => {
|
||||||
await testElementLength(".calendar .event", 10);
|
await expect(testElementLength(".calendar .event", 10)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the default calendar symbol in each event", async () => {
|
it("should show the default calendar symbol in each event", async () => {
|
||||||
await testElementLength(".calendar .event .fa-calendar-alt", 0, "not");
|
await expect(testElementLength(".calendar .event .fa-calendar-alt", 0, "not")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -49,27 +52,27 @@ describe("Calendar module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should show the custom maximumEntries of 5", async () => {
|
it("should show the custom maximumEntries of 5", async () => {
|
||||||
await testElementLength(".calendar .event", 5);
|
await expect(testElementLength(".calendar .event", 5)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the custom calendar symbol in four events", async () => {
|
it("should show the custom calendar symbol in four events", async () => {
|
||||||
await testElementLength(".calendar .event .fa-birthday-cake", 4);
|
await expect(testElementLength(".calendar .event .fa-birthday-cake", 4)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show a customEvent calendar symbol in one event", async () => {
|
it("should show a customEvent calendar symbol in one event", async () => {
|
||||||
await testElementLength(".calendar .event .fa-dice", 1);
|
await expect(testElementLength(".calendar .event .fa-dice", 1)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show a customEvent calendar eventClass in one event", async () => {
|
it("should show a customEvent calendar eventClass in one event", async () => {
|
||||||
await testElementLength(".calendar .event.undo", 1);
|
await expect(testElementLength(".calendar .event.undo", 1)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show two custom icons for repeating events", async () => {
|
it("should show two custom icons for repeating events", async () => {
|
||||||
await testElementLength(".calendar .event .fa-undo", 2);
|
await expect(testElementLength(".calendar .event .fa-undo", 2)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show two custom icons for day events", async () => {
|
it("should show two custom icons for day events", async () => {
|
||||||
await testElementLength(".calendar .event .fa-calendar-day", 2);
|
await expect(testElementLength(".calendar .event .fa-calendar-day", 2)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -80,7 +83,7 @@ describe("Calendar module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should show the recurring birthday event 6 times", async () => {
|
it("should show the recurring birthday event 6 times", async () => {
|
||||||
await testElementLength(".calendar .event", 6);
|
await expect(testElementLength(".calendar .event", 6)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -91,7 +94,7 @@ describe("Calendar module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should show the recurring event 51 times (excluded once) in a 364-day (inclusive) period", async () => {
|
it("should show the recurring event 51 times (excluded once) in a 364-day (inclusive) period", async () => {
|
||||||
await testElementLength(".calendar .event", 51);
|
await expect(testElementLength(".calendar .event", 51)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -102,7 +105,7 @@ describe("Calendar module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should show multiple events with the same title and start time from different calendars", async () => {
|
it("should show multiple events with the same title and start time from different calendars", async () => {
|
||||||
await testElementLength(".calendar .event", 22);
|
await expect(testElementLength(".calendar .event", 22)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -118,7 +121,7 @@ describe("Calendar module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it(`should contain text "Mar 25th" in timezone UTC ${-i}`, async () => {
|
it(`should contain text "Mar 25th" in timezone UTC ${-i}`, async () => {
|
||||||
await testTextContain(".calendar", "Mar 25th");
|
await expect(testTextContain(".calendar", "Mar 25th")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -135,7 +138,7 @@ describe("Calendar module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should return TestEvents", async () => {
|
it("should return TestEvents", async () => {
|
||||||
await testElementLength(".calendar .event", 0, "not");
|
await expect(testElementLength(".calendar .event", 0, "not")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -146,7 +149,7 @@ describe("Calendar module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should return TestEvents", async () => {
|
it("should return TestEvents", async () => {
|
||||||
await testElementLength(".calendar .event", 0, "not");
|
await expect(testElementLength(".calendar .event", 0, "not")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -157,7 +160,7 @@ describe("Calendar module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should return TestEvents", async () => {
|
it("should return TestEvents", async () => {
|
||||||
await testElementLength(".calendar .event", 0, "not");
|
await expect(testElementLength(".calendar .event", 0, "not")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -168,7 +171,7 @@ describe("Calendar module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should return TestEvents", async () => {
|
it("should return TestEvents", async () => {
|
||||||
await testElementLength(".calendar .event", 0, "not");
|
await expect(testElementLength(".calendar .event", 0, "not")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -184,7 +187,7 @@ describe("Calendar module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should show Unauthorized error", async () => {
|
it("should show Unauthorized error", async () => {
|
||||||
await testTextContain(".calendar", "Error in the calendar module. Authorization failed");
|
await expect(testTextContain(".calendar", "Error in the calendar module. Authorization failed")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -13,12 +13,12 @@ describe("Clock set to spanish language module", () => {
|
|||||||
|
|
||||||
it("shows date with correct format", async () => {
|
it("shows date with correct format", async () => {
|
||||||
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
|
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
|
||||||
await helpers.testMatch(".clock .date", dateRegex);
|
await expect(helpers.testMatch(".clock .date", dateRegex)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows time in 24hr format", async () => {
|
it("shows time in 24hr format", async () => {
|
||||||
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
|
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
|
||||||
await helpers.testMatch(".clock .time", timeRegex);
|
await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -30,12 +30,12 @@ describe("Clock set to spanish language module", () => {
|
|||||||
|
|
||||||
it("shows date with correct format", async () => {
|
it("shows date with correct format", async () => {
|
||||||
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
|
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
|
||||||
await helpers.testMatch(".clock .date", dateRegex);
|
await expect(helpers.testMatch(".clock .date", dateRegex)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows time in 12hr format", async () => {
|
it("shows time in 12hr format", async () => {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
||||||
await helpers.testMatch(".clock .time", timeRegex);
|
await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ describe("Clock set to spanish language module", () => {
|
|||||||
|
|
||||||
it("shows 12hr time with upper case AM/PM", async () => {
|
it("shows 12hr time with upper case AM/PM", async () => {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
||||||
await helpers.testMatch(".clock .time", timeRegex);
|
await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ describe("Clock set to spanish language module", () => {
|
|||||||
|
|
||||||
it("shows week with correct format", async () => {
|
it("shows week with correct format", async () => {
|
||||||
const weekRegex = /^Semana [0-9]{1,2}$/;
|
const weekRegex = /^Semana [0-9]{1,2}$/;
|
||||||
await helpers.testMatch(".clock .week", weekRegex);
|
await expect(helpers.testMatch(".clock .week", weekRegex)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -14,12 +14,12 @@ describe("Clock module", () => {
|
|||||||
|
|
||||||
it("should show the date in the correct format", async () => {
|
it("should show the date in the correct format", async () => {
|
||||||
const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
|
const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
|
||||||
await helpers.testMatch(".clock .date", dateRegex);
|
await expect(helpers.testMatch(".clock .date", dateRegex)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the time in 24hr format", async () => {
|
it("should show the time in 24hr format", async () => {
|
||||||
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
|
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
|
||||||
await helpers.testMatch(".clock .time", timeRegex);
|
await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -31,12 +31,12 @@ describe("Clock module", () => {
|
|||||||
|
|
||||||
it("should show the date in the correct format", async () => {
|
it("should show the date in the correct format", async () => {
|
||||||
const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
|
const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
|
||||||
await helpers.testMatch(".clock .date", dateRegex);
|
await expect(helpers.testMatch(".clock .date", dateRegex)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the time in 12hr format", async () => {
|
it("should show the time in 12hr format", async () => {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
||||||
await helpers.testMatch(".clock .time", timeRegex);
|
await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ describe("Clock module", () => {
|
|||||||
|
|
||||||
it("should show 12hr time with upper case AM/PM", async () => {
|
it("should show 12hr time with upper case AM/PM", async () => {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
||||||
await helpers.testMatch(".clock .time", timeRegex);
|
await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ describe("Clock module", () => {
|
|||||||
|
|
||||||
it("should show 12hr time without seconds am/pm", async () => {
|
it("should show 12hr time without seconds am/pm", async () => {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
|
||||||
await helpers.testMatch(".clock .time", timeRegex);
|
await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ describe("Clock module", () => {
|
|||||||
|
|
||||||
it("should show the week in the correct format", async () => {
|
it("should show the week in the correct format", async () => {
|
||||||
const weekRegex = /^Week [0-9]{1,2}$/;
|
const weekRegex = /^Week [0-9]{1,2}$/;
|
||||||
await helpers.testMatch(".clock .week", weekRegex);
|
await expect(helpers.testMatch(".clock .week", weekRegex)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the week with the correct number of week of year", async () => {
|
it("should show the week with the correct number of week of year", async () => {
|
||||||
|
@ -4,6 +4,7 @@ describe("Compliments module", () => {
|
|||||||
/**
|
/**
|
||||||
* move similar tests in function doTest
|
* move similar tests in function doTest
|
||||||
* @param {Array} complimentsArray The array of compliments.
|
* @param {Array} complimentsArray The array of compliments.
|
||||||
|
* @returns {boolean} result
|
||||||
*/
|
*/
|
||||||
const doTest = async (complimentsArray) => {
|
const doTest = async (complimentsArray) => {
|
||||||
let elem = await helpers.waitForElement(".compliments");
|
let elem = await helpers.waitForElement(".compliments");
|
||||||
@ -11,6 +12,7 @@ describe("Compliments module", () => {
|
|||||||
elem = await helpers.waitForElement(".module-content");
|
elem = await helpers.waitForElement(".module-content");
|
||||||
expect(elem).not.toBeNull();
|
expect(elem).not.toBeNull();
|
||||||
expect(complimentsArray).toContain(elem.textContent);
|
expect(complimentsArray).toContain(elem.textContent);
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
@ -25,7 +27,7 @@ describe("Compliments module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("shows anytime because if configure empty parts of day compliments and set anytime compliments", async () => {
|
it("shows anytime because if configure empty parts of day compliments and set anytime compliments", async () => {
|
||||||
await doTest(["Anytime here"]);
|
await expect(doTest(["Anytime here"])).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -36,7 +38,7 @@ describe("Compliments module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("shows anytime compliments", async () => {
|
it("shows anytime compliments", async () => {
|
||||||
await doTest(["Anytime here"]);
|
await expect(doTest(["Anytime here"])).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -48,7 +50,7 @@ describe("Compliments module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should show compliments from a remote file", async () => {
|
it("should show compliments from a remote file", async () => {
|
||||||
await doTest(["Remote compliment file works!"]);
|
await expect(doTest(["Remote compliment file works!"])).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -15,15 +15,15 @@ describe("Weather module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should render wind speed and wind direction", async () => {
|
it("should render wind speed and wind direction", async () => {
|
||||||
await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "12 WSW");
|
await expect(weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "12 WSW")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render temperature with icon", async () => {
|
it("should render temperature with icon", async () => {
|
||||||
await weatherFunc.getText(".weather .large.light span.bright", "1.5°");
|
await expect(weatherFunc.getText(".weather .large.light span.bright", "1.5°")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render feels like temperature", async () => {
|
it("should render feels like temperature", async () => {
|
||||||
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -5.6°");
|
await expect(weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -5.6°")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -34,7 +34,7 @@ describe("Weather module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should render a compliment based on the current weather", async () => {
|
it("should render a compliment based on the current weather", async () => {
|
||||||
await weatherFunc.getText(".compliments .module-content span", "snow");
|
await expect(weatherFunc.getText(".compliments .module-content span", "snow")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ describe("Weather module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should render windUnits in beaufort", async () => {
|
it("should render windUnits in beaufort", async () => {
|
||||||
await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "6");
|
await expect(weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "6")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render windDirection with an arrow", async () => {
|
it("should render windDirection with an arrow", async () => {
|
||||||
@ -54,15 +54,15 @@ describe("Weather module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should render humidity", async () => {
|
it("should render humidity", async () => {
|
||||||
await weatherFunc.getText(".weather .normal.medium span:nth-child(3)", "93.7");
|
await expect(weatherFunc.getText(".weather .normal.medium span:nth-child(3)", "93.7")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render degreeLabel for temp", async () => {
|
it("should render degreeLabel for temp", async () => {
|
||||||
await weatherFunc.getText(".weather .large.light span.bright", "1°C");
|
await expect(weatherFunc.getText(".weather .large.light span.bright", "1°C")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render degreeLabel for feels like", async () => {
|
it("should render degreeLabel for feels like", async () => {
|
||||||
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C");
|
await expect(weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -72,15 +72,15 @@ describe("Weather module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should render wind in imperial units", async () => {
|
it("should render wind in imperial units", async () => {
|
||||||
await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "26 WSW");
|
await expect(weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "26 WSW")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render temperatures in fahrenheit", async () => {
|
it("should render temperatures in fahrenheit", async () => {
|
||||||
await weatherFunc.getText(".weather .large.light span.bright", "34,7°");
|
await expect(weatherFunc.getText(".weather .large.light span.bright", "34,7°")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render 'feels like' in fahrenheit", async () => {
|
it("should render 'feels like' in fahrenheit", async () => {
|
||||||
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 21,9°");
|
await expect(weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 21,9°")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -16,7 +16,7 @@ describe("Weather module: Weather Forecast", () => {
|
|||||||
const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"];
|
const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"];
|
||||||
for (const [index, day] of days.entries()) {
|
for (const [index, day] of days.entries()) {
|
||||||
it(`should render day ${day}`, async () => {
|
it(`should render day ${day}`, async () => {
|
||||||
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
|
await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,14 +31,14 @@ describe("Weather module: Weather Forecast", () => {
|
|||||||
const maxTemps = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"];
|
const maxTemps = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"];
|
||||||
for (const [index, temp] of maxTemps.entries()) {
|
for (const [index, temp] of maxTemps.entries()) {
|
||||||
it(`should render max temperature ${temp}`, async () => {
|
it(`should render max temperature ${temp}`, async () => {
|
||||||
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
|
await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const minTemps = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"];
|
const minTemps = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"];
|
||||||
for (const [index, temp] of minTemps.entries()) {
|
for (const [index, temp] of minTemps.entries()) {
|
||||||
it(`should render min temperature ${temp}`, async () => {
|
it(`should render min temperature ${temp}`, async () => {
|
||||||
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp);
|
await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ describe("Weather module: Weather Forecast", () => {
|
|||||||
const days = ["Fri", "Sat", "Sun", "Mon", "Tue"];
|
const days = ["Fri", "Sat", "Sun", "Mon", "Tue"];
|
||||||
for (const [index, day] of days.entries()) {
|
for (const [index, day] of days.entries()) {
|
||||||
it(`should render day ${day}`, async () => {
|
it(`should render day ${day}`, async () => {
|
||||||
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
|
await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -86,7 +86,7 @@ describe("Weather module: Weather Forecast", () => {
|
|||||||
for (const [index, precipitation] of precipitations.entries()) {
|
for (const [index, precipitation] of precipitations.entries()) {
|
||||||
if (precipitation) {
|
if (precipitation) {
|
||||||
it(`should render precipitation amount ${precipitation}`, async () => {
|
it(`should render precipitation amount ${precipitation}`, async () => {
|
||||||
await weatherFunc.getText(`.weather table tr:nth-child(${index + 1}) td.precipitation-amount`, precipitation);
|
await expect(weatherFunc.getText(`.weather table tr:nth-child(${index + 1}) td.precipitation-amount`, precipitation)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ describe("Weather module: Weather Forecast", () => {
|
|||||||
const temperatures = ["75_9°", "69_8°", "73_2°", "74_1°", "69_1°"];
|
const temperatures = ["75_9°", "69_8°", "73_2°", "74_1°", "69_1°"];
|
||||||
for (const [index, temp] of temperatures.entries()) {
|
for (const [index, temp] of temperatures.entries()) {
|
||||||
it(`should render custom decimalSymbol = '_' for temp ${temp}`, async () => {
|
it(`should render custom decimalSymbol = '_' for temp ${temp}`, async () => {
|
||||||
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
|
await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -111,7 +111,7 @@ describe("Weather module: Weather Forecast", () => {
|
|||||||
for (const [index, precipitation] of precipitations.entries()) {
|
for (const [index, precipitation] of precipitations.entries()) {
|
||||||
if (precipitation) {
|
if (precipitation) {
|
||||||
it(`should render precipitation amount ${precipitation}`, async () => {
|
it(`should render precipitation amount ${precipitation}`, async () => {
|
||||||
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-amount`, precipitation);
|
await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-amount`, precipitation)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ describe("Weather module: Weather Hourly Forecast", () => {
|
|||||||
const minTemps = ["7:00 pm", "8:00 pm", "9:00 pm", "10:00 pm", "11:00 pm"];
|
const minTemps = ["7:00 pm", "8:00 pm", "9:00 pm", "10:00 pm", "11:00 pm"];
|
||||||
for (const [index, hour] of minTemps.entries()) {
|
for (const [index, hour] of minTemps.entries()) {
|
||||||
it(`should render forecast for hour ${hour}`, async () => {
|
it(`should render forecast for hour ${hour}`, async () => {
|
||||||
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.day`, hour);
|
await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.day`, hour)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -30,7 +30,7 @@ describe("Weather module: Weather Hourly Forecast", () => {
|
|||||||
const minTemps = ["7:00 pm", "9:00 pm", "11:00 pm", "1:00 am", "3:00 am"];
|
const minTemps = ["7:00 pm", "9:00 pm", "11:00 pm", "1:00 am", "3:00 am"];
|
||||||
for (const [index, hour] of minTemps.entries()) {
|
for (const [index, hour] of minTemps.entries()) {
|
||||||
it(`should render forecast for hour ${hour}`, async () => {
|
it(`should render forecast for hour ${hour}`, async () => {
|
||||||
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.day`, hour);
|
await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.day`, hour)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -46,7 +46,7 @@ describe("Weather module: Weather Hourly Forecast", () => {
|
|||||||
for (const [index, amount] of amounts.entries()) {
|
for (const [index, amount] of amounts.entries()) {
|
||||||
if (amount) {
|
if (amount) {
|
||||||
it(`should render precipitation amount ${amount}`, async () => {
|
it(`should render precipitation amount ${amount}`, async () => {
|
||||||
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-amount`, amount);
|
await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-amount`, amount)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ describe("Weather module: Weather Hourly Forecast", () => {
|
|||||||
for (const [index, pop] of propabilities.entries()) {
|
for (const [index, pop] of propabilities.entries()) {
|
||||||
if (pop) {
|
if (pop) {
|
||||||
it(`should render probability ${pop}`, async () => {
|
it(`should render probability ${pop}`, async () => {
|
||||||
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-prob`, pop);
|
await expect(weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-prob`, pop)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,8 @@ describe("Translations", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should load translation file", (done) => {
|
it("should load translation file", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
dom.window.onload = async () => {
|
dom.window.onload = async () => {
|
||||||
const { Translator, Module, config } = dom.window;
|
const { Translator, Module, config } = dom.window;
|
||||||
config.language = "en";
|
config.language = "en";
|
||||||
@ -61,8 +62,10 @@ describe("Translations", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should load translation + fallback file", (done) => {
|
it("should load translation + fallback file", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
dom.window.onload = async () => {
|
dom.window.onload = async () => {
|
||||||
const { Translator, Module } = dom.window;
|
const { Translator, Module } = dom.window;
|
||||||
Translator.load = sinon.stub().callsFake((_m, _f, _fb) => null);
|
Translator.load = sinon.stub().callsFake((_m, _f, _fb) => null);
|
||||||
@ -79,8 +82,10 @@ describe("Translations", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should load translation fallback file", (done) => {
|
it("should load translation fallback file", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
dom.window.onload = async () => {
|
dom.window.onload = async () => {
|
||||||
const { Translator, Module, config } = dom.window;
|
const { Translator, Module, config } = dom.window;
|
||||||
config.language = "--";
|
config.language = "--";
|
||||||
@ -97,8 +102,10 @@ describe("Translations", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should load no file", (done) => {
|
it("should load no file", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
dom.window.onload = async () => {
|
dom.window.onload = async () => {
|
||||||
const { Translator, Module } = dom.window;
|
const { Translator, Module } = dom.window;
|
||||||
Translator.load = sinon.stub();
|
Translator.load = sinon.stub();
|
||||||
@ -114,6 +121,7 @@ describe("Translations", () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const mmm = {
|
const mmm = {
|
||||||
name: "TranslationTest",
|
name: "TranslationTest",
|
||||||
@ -124,7 +132,8 @@ describe("Translations", () => {
|
|||||||
|
|
||||||
describe("Parsing language files through the Translator class", () => {
|
describe("Parsing language files through the Translator class", () => {
|
||||||
for (let language in translations) {
|
for (let language in translations) {
|
||||||
it(`should parse ${language}`, (done) => {
|
it(`should parse ${language}`, () => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(
|
const dom = new JSDOM(
|
||||||
`<script>var translations = ${JSON.stringify(translations)}; var Log = {log: () => {}};</script>\
|
`<script>var translations = ${JSON.stringify(translations)}; var Log = {log: () => {}};</script>\
|
||||||
<script src="file://${path.join(__dirname, "..", "..", "js", "translator.js")}">`,
|
<script src="file://${path.join(__dirname, "..", "..", "js", "translator.js")}">`,
|
||||||
@ -139,6 +148,7 @@ describe("Translations", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -146,7 +156,8 @@ describe("Translations", () => {
|
|||||||
let base;
|
let base;
|
||||||
let missing = [];
|
let missing = [];
|
||||||
|
|
||||||
beforeAll((done) => {
|
beforeAll(() => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(
|
const dom = new JSDOM(
|
||||||
`<script>var translations = ${JSON.stringify(translations)}; var Log = {log: () => {}};</script>\
|
`<script>var translations = ${JSON.stringify(translations)}; var Log = {log: () => {}};</script>\
|
||||||
<script src="file://${path.join(__dirname, "..", "..", "js", "translator.js")}">`,
|
<script src="file://${path.join(__dirname, "..", "..", "js", "translator.js")}">`,
|
||||||
@ -160,6 +171,7 @@ describe("Translations", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
console.log(missing);
|
console.log(missing);
|
||||||
@ -175,7 +187,8 @@ describe("Translations", () => {
|
|||||||
describe(`Translation keys of ${language}`, () => {
|
describe(`Translation keys of ${language}`, () => {
|
||||||
let keys;
|
let keys;
|
||||||
|
|
||||||
beforeAll((done) => {
|
beforeAll(() => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(
|
const dom = new JSDOM(
|
||||||
`<script>var translations = ${JSON.stringify(translations)}; var Log = {log: () => {}};</script>\
|
`<script>var translations = ${JSON.stringify(translations)}; var Log = {log: () => {}};</script>\
|
||||||
<script src="file://${path.join(__dirname, "..", "..", "js", "translator.js")}">`,
|
<script src="file://${path.join(__dirname, "..", "..", "js", "translator.js")}">`,
|
||||||
@ -189,6 +202,7 @@ describe("Translations", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it(`${language} keys should be in base`, () => {
|
it(`${language} keys should be in base`, () => {
|
||||||
keys.forEach((key) => {
|
keys.forEach((key) => {
|
||||||
|
@ -11,6 +11,7 @@ exports.getText = async (element, result) => {
|
|||||||
.replace(/(\r\n|\n|\r)/gm, "")
|
.replace(/(\r\n|\n|\r)/gm, "")
|
||||||
.replace(/[ ]+/g, " ")
|
.replace(/[ ]+/g, " ")
|
||||||
).toBe(result);
|
).toBe(result);
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.startApp = async (configFileName, systemDate) => {
|
exports.startApp = async (configFileName, systemDate) => {
|
||||||
|
@ -4,10 +4,12 @@ describe("Calendar module", () => {
|
|||||||
/**
|
/**
|
||||||
* move similar tests in function doTest
|
* move similar tests in function doTest
|
||||||
* @param {string} cssClass css selector
|
* @param {string} cssClass css selector
|
||||||
|
* @returns {boolean} result
|
||||||
*/
|
*/
|
||||||
const doTest = async (cssClass) => {
|
const doTest = async (cssClass) => {
|
||||||
let elem = await helpers.getElement(`.calendar .module-content .event${cssClass}`);
|
let elem = await helpers.getElement(`.calendar .module-content .event${cssClass}`);
|
||||||
await expect(elem.isVisible()).resolves.toBe(true);
|
await expect(elem.isVisible()).resolves.toBe(true);
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
@ -17,27 +19,27 @@ describe("Calendar module", () => {
|
|||||||
describe("Test css classes", () => {
|
describe("Test css classes", () => {
|
||||||
it("has css class dayBeforeYesterday", async () => {
|
it("has css class dayBeforeYesterday", async () => {
|
||||||
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "03 Jan 2030 12:30:00 GMT");
|
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "03 Jan 2030 12:30:00 GMT");
|
||||||
await doTest(".dayBeforeYesterday");
|
await expect(doTest(".dayBeforeYesterday")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has css class yesterday", async () => {
|
it("has css class yesterday", async () => {
|
||||||
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "02 Jan 2030 12:30:00 GMT");
|
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "02 Jan 2030 12:30:00 GMT");
|
||||||
await doTest(".yesterday");
|
await expect(doTest(".yesterday")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has css class today", async () => {
|
it("has css class today", async () => {
|
||||||
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "01 Jan 2030 12:30:00 GMT");
|
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "01 Jan 2030 12:30:00 GMT");
|
||||||
await doTest(".today");
|
await expect(doTest(".today")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has css class tomorrow", async () => {
|
it("has css class tomorrow", async () => {
|
||||||
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "31 Dec 2029 12:30:00 GMT");
|
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "31 Dec 2029 12:30:00 GMT");
|
||||||
await doTest(".tomorrow");
|
await expect(doTest(".tomorrow")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has css class dayAfterTomorrow", async () => {
|
it("has css class dayAfterTomorrow", async () => {
|
||||||
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "30 Dec 2029 12:30:00 GMT");
|
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "30 Dec 2029 12:30:00 GMT");
|
||||||
await doTest(".dayAfterTomorrow");
|
await expect(doTest(".dayAfterTomorrow")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -4,12 +4,14 @@ describe("Compliments module", () => {
|
|||||||
/**
|
/**
|
||||||
* move similar tests in function doTest
|
* move similar tests in function doTest
|
||||||
* @param {Array} complimentsArray The array of compliments.
|
* @param {Array} complimentsArray The array of compliments.
|
||||||
|
* @returns {boolean} result
|
||||||
*/
|
*/
|
||||||
const doTest = async (complimentsArray) => {
|
const doTest = async (complimentsArray) => {
|
||||||
await helpers.getElement(".compliments");
|
await helpers.getElement(".compliments");
|
||||||
const elem = await helpers.getElement(".module-content");
|
const elem = await helpers.getElement(".module-content");
|
||||||
expect(elem).not.toBeNull();
|
expect(elem).not.toBeNull();
|
||||||
expect(complimentsArray).toContain(await elem.textContent());
|
expect(complimentsArray).toContain(await elem.textContent());
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
@ -19,17 +21,17 @@ describe("Compliments module", () => {
|
|||||||
describe("parts of days", () => {
|
describe("parts of days", () => {
|
||||||
it("Morning compliments for that part of day", async () => {
|
it("Morning compliments for that part of day", async () => {
|
||||||
await helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js", "01 Oct 2022 10:00:00 GMT");
|
await helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js", "01 Oct 2022 10:00:00 GMT");
|
||||||
await doTest(["Hi", "Good Morning", "Morning test"]);
|
await expect(doTest(["Hi", "Good Morning", "Morning test"])).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Afternoon show Compliments for that part of day", async () => {
|
it("Afternoon show Compliments for that part of day", async () => {
|
||||||
await helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js", "01 Oct 2022 15:00:00 GMT");
|
await helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js", "01 Oct 2022 15:00:00 GMT");
|
||||||
await doTest(["Hello", "Good Afternoon", "Afternoon test"]);
|
await expect(doTest(["Hello", "Good Afternoon", "Afternoon test"])).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Evening show Compliments for that part of day", async () => {
|
it("Evening show Compliments for that part of day", async () => {
|
||||||
await helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js", "01 Oct 2022 20:00:00 GMT");
|
await helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js", "01 Oct 2022 20:00:00 GMT");
|
||||||
await doTest(["Hello There", "Good Evening", "Evening test"]);
|
await expect(doTest(["Hello There", "Good Evening", "Evening test"])).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -37,7 +39,7 @@ describe("Compliments module", () => {
|
|||||||
describe("Set date and empty compliments for anytime, morning, evening and afternoon", () => {
|
describe("Set date and empty compliments for anytime, morning, evening and afternoon", () => {
|
||||||
it("shows happy new year compliment on new years day", async () => {
|
it("shows happy new year compliment on new years day", async () => {
|
||||||
await helpers.startApplication("tests/configs/modules/compliments/compliments_date.js", "01 Jan 2022 10:00:00 GMT");
|
await helpers.startApplication("tests/configs/modules/compliments/compliments_date.js", "01 Jan 2022 10:00:00 GMT");
|
||||||
await doTest(["Happy new year!"]);
|
await expect(doTest(["Happy new year!"])).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,7 @@ describe("Weather module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should render sunrise", async () => {
|
it("should render sunrise", async () => {
|
||||||
await weatherHelper.getText(".weather .normal.medium span:nth-child(4)", "7:00 am");
|
await expect(weatherHelper.getText(".weather .normal.medium span:nth-child(4)", "7:00 am")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ describe("Weather module", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should render sunset", async () => {
|
it("should render sunset", async () => {
|
||||||
await weatherHelper.getText(".weather .normal.medium span:nth-child(4)", "3:45 pm");
|
await expect(weatherHelper.getText(".weather .normal.medium span:nth-child(4)", "3:45 pm")).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -6,7 +6,8 @@ describe("File js/class", () => {
|
|||||||
let clone;
|
let clone;
|
||||||
let dom;
|
let dom;
|
||||||
|
|
||||||
beforeAll((done) => {
|
beforeAll(() => {
|
||||||
|
return new Promise((done) => {
|
||||||
dom = new JSDOM(
|
dom = new JSDOM(
|
||||||
`<script>var Log = {log: () => {}};</script>\
|
`<script>var Log = {log: () => {}};</script>\
|
||||||
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "class.js")}">`,
|
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "class.js")}">`,
|
||||||
@ -18,6 +19,7 @@ describe("File js/class", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should clone object", () => {
|
it("should clone object", () => {
|
||||||
const expected = { name: "Rodrigo", web: "https://rodrigoramirez.com", project: "MagicMirror" };
|
const expected = { name: "Rodrigo", web: "https://rodrigoramirez.com", project: "MagicMirror" };
|
||||||
|
@ -77,7 +77,8 @@ describe("Translator", () => {
|
|||||||
Translator.coreTranslationsFallback = coreTranslationsFallback;
|
Translator.coreTranslationsFallback = coreTranslationsFallback;
|
||||||
};
|
};
|
||||||
|
|
||||||
it("should return custom module translation", (done) => {
|
it("should return custom module translation", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(`<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
const dom = new JSDOM(`<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
||||||
dom.window.onload = () => {
|
dom.window.onload = () => {
|
||||||
const { Translator } = dom.window;
|
const { Translator } = dom.window;
|
||||||
@ -89,8 +90,10 @@ describe("Translator", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should return core translation", (done) => {
|
it("should return core translation", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(`<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
const dom = new JSDOM(`<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
||||||
dom.window.onload = () => {
|
dom.window.onload = () => {
|
||||||
const { Translator } = dom.window;
|
const { Translator } = dom.window;
|
||||||
@ -102,8 +105,10 @@ describe("Translator", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should return custom module translation fallback", (done) => {
|
it("should return custom module translation fallback", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(`<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
const dom = new JSDOM(`<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
||||||
dom.window.onload = () => {
|
dom.window.onload = () => {
|
||||||
const { Translator } = dom.window;
|
const { Translator } = dom.window;
|
||||||
@ -113,8 +118,10 @@ describe("Translator", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should return core translation fallback", (done) => {
|
it("should return core translation fallback", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(`<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
const dom = new JSDOM(`<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
||||||
dom.window.onload = () => {
|
dom.window.onload = () => {
|
||||||
const { Translator } = dom.window;
|
const { Translator } = dom.window;
|
||||||
@ -124,8 +131,10 @@ describe("Translator", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should return translation with placeholder for missing variables", (done) => {
|
it("should return translation with placeholder for missing variables", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(`<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
const dom = new JSDOM(`<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
||||||
dom.window.onload = () => {
|
dom.window.onload = () => {
|
||||||
const { Translator } = dom.window;
|
const { Translator } = dom.window;
|
||||||
@ -135,8 +144,10 @@ describe("Translator", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should return key if no translation was found", (done) => {
|
it("should return key if no translation was found", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(`<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
const dom = new JSDOM(`<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
||||||
dom.window.onload = () => {
|
dom.window.onload = () => {
|
||||||
const { Translator } = dom.window;
|
const { Translator } = dom.window;
|
||||||
@ -147,6 +158,7 @@ describe("Translator", () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("load", () => {
|
describe("load", () => {
|
||||||
const mmm = {
|
const mmm = {
|
||||||
@ -156,7 +168,8 @@ describe("Translator", () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
it("should load translations", (done) => {
|
it("should load translations", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(`<script>var Log = {log: () => {}};</script><script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
const dom = new JSDOM(`<script>var Log = {log: () => {}};</script><script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
||||||
dom.window.onload = async () => {
|
dom.window.onload = async () => {
|
||||||
const { Translator } = dom.window;
|
const { Translator } = dom.window;
|
||||||
@ -168,8 +181,10 @@ describe("Translator", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should load translation fallbacks", (done) => {
|
it("should load translation fallbacks", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(`<script>var Log = {log: () => {}};</script><script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
const dom = new JSDOM(`<script>var Log = {log: () => {}};</script><script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
||||||
dom.window.onload = async () => {
|
dom.window.onload = async () => {
|
||||||
const { Translator } = dom.window;
|
const { Translator } = dom.window;
|
||||||
@ -181,8 +196,10 @@ describe("Translator", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should not load translations, if module fallback exists", (done) => {
|
it("should not load translations, if module fallback exists", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(`<script>var Log = {log: () => {}};</script><script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
const dom = new JSDOM(`<script>var Log = {log: () => {}};</script><script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`, { runScripts: "dangerously", resources: "usable" });
|
||||||
dom.window.onload = async () => {
|
dom.window.onload = async () => {
|
||||||
const { Translator, XMLHttpRequest } = dom.window;
|
const { Translator, XMLHttpRequest } = dom.window;
|
||||||
@ -205,9 +222,11 @@ describe("Translator", () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("loadCoreTranslations", () => {
|
describe("loadCoreTranslations", () => {
|
||||||
it("should load core translations and fallback", (done) => {
|
it("should load core translations and fallback", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(
|
const dom = new JSDOM(
|
||||||
`<script>var translations = {en: "http://localhost:3000/translations/translation_test.json"}; var Log = {log: () => {}};</script>\
|
`<script>var translations = {en: "http://localhost:3000/translations/translation_test.json"}; var Log = {log: () => {}};</script>\
|
||||||
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
|
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
|
||||||
@ -225,8 +244,10 @@ describe("Translator", () => {
|
|||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should load core fallback if language cannot be found", (done) => {
|
it("should load core fallback if language cannot be found", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(
|
const dom = new JSDOM(
|
||||||
`<script>var translations = {en: "http://localhost:3000/translations/translation_test.json"}; var Log = {log: () => {}};</script>\
|
`<script>var translations = {en: "http://localhost:3000/translations/translation_test.json"}; var Log = {log: () => {}};</script>\
|
||||||
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
|
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
|
||||||
@ -245,9 +266,11 @@ describe("Translator", () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("loadCoreTranslationsFallback", () => {
|
describe("loadCoreTranslationsFallback", () => {
|
||||||
it("should load core translations fallback", (done) => {
|
it("should load core translations fallback", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(
|
const dom = new JSDOM(
|
||||||
`<script>var translations = {en: "http://localhost:3000/translations/translation_test.json"}; var Log = {log: () => {}};</script>\
|
`<script>var translations = {en: "http://localhost:3000/translations/translation_test.json"}; var Log = {log: () => {}};</script>\
|
||||||
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
|
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
|
||||||
@ -264,8 +287,10 @@ describe("Translator", () => {
|
|||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should load core fallback if language cannot be found", (done) => {
|
it("should load core fallback if language cannot be found", () => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(
|
const dom = new JSDOM(
|
||||||
`<script>var translations = {}; var Log = {log: () => {}};</script>\
|
`<script>var translations = {}; var Log = {log: () => {}};</script>\
|
||||||
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
|
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "translator.js")}">`,
|
||||||
@ -282,4 +307,5 @@ describe("Translator", () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,8 @@ const { JSDOM } = require("jsdom");
|
|||||||
describe("Test function cmpVersions in js/module.js", () => {
|
describe("Test function cmpVersions in js/module.js", () => {
|
||||||
let cmp;
|
let cmp;
|
||||||
|
|
||||||
beforeAll((done) => {
|
beforeAll(() => {
|
||||||
|
return new Promise((done) => {
|
||||||
const dom = new JSDOM(
|
const dom = new JSDOM(
|
||||||
`<script>var Class = {extend: () => { return {}; }};</script>\
|
`<script>var Class = {extend: () => { return {}; }};</script>\
|
||||||
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "module.js")}">`,
|
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "module.js")}">`,
|
||||||
@ -16,6 +17,7 @@ describe("Test function cmpVersions in js/module.js", () => {
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should return -1 when comparing 2.1 to 2.2", () => {
|
it("should return -1 when comparing 2.1 to 2.2", () => {
|
||||||
expect(cmp("2.1", "2.2")).toBe(-1);
|
expect(cmp("2.1", "2.2")).toBe(-1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user