mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
update clock tests, remove testSequencer
This commit is contained in:
@@ -93,7 +93,6 @@
|
||||
},
|
||||
"jest": {
|
||||
"verbose": true,
|
||||
"testSequencer": "<rootDir>/tests/e2e/testSequencer.js",
|
||||
"projects": [
|
||||
{
|
||||
"displayName": "unit",
|
||||
@@ -120,7 +119,6 @@
|
||||
],
|
||||
"testPathIgnorePatterns": [
|
||||
"<rootDir>/tests/e2e/modules/mocks",
|
||||
"<rootDir>/tests/e2e/testSequencer.js",
|
||||
"<rootDir>/tests/e2e/global-setup.js"
|
||||
]
|
||||
}
|
||||
|
@@ -5,6 +5,13 @@ describe("Clock set to spanish language module", function () {
|
||||
|
||||
let app = null;
|
||||
|
||||
testMatch = async function (element, regex) {
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
const elem = await app.client.$(element);
|
||||
const txt = await elem.getText(element);
|
||||
return txt.match(regex);
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
return helpers
|
||||
.startApplication({
|
||||
@@ -27,14 +34,12 @@ describe("Clock set to spanish language module", function () {
|
||||
|
||||
it("shows date with correct format", async function () {
|
||||
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 elem = await app.client.$(".clock .date");
|
||||
return elem.getText(".clock .date").toString().match(dateRegex);
|
||||
return testMatch(".clock .date", dateRegex);
|
||||
});
|
||||
|
||||
it("shows time in 24hr format", async function () {
|
||||
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
|
||||
const elem = await app.client.$(".clock .time");
|
||||
return elem.getText(".clock .time").toString().match(timeRegex);
|
||||
return testMatch(".clock .time", timeRegex);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,14 +51,12 @@ describe("Clock set to spanish language module", function () {
|
||||
|
||||
it("shows date with correct format", async function () {
|
||||
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 elem = await app.client.$(".clock .date");
|
||||
return elem.getText(".clock .date").toString().match(dateRegex);
|
||||
return testMatch(".clock .date", dateRegex);
|
||||
});
|
||||
|
||||
it("shows time in 12hr format", async function () {
|
||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
||||
const elem = await app.client.$(".clock .time");
|
||||
return elem.getText(".clock .time").toString().match(timeRegex);
|
||||
return testMatch(".clock .time", timeRegex);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -65,8 +68,7 @@ describe("Clock set to spanish language module", function () {
|
||||
|
||||
it("shows 12hr time with upper case AM/PM", async function () {
|
||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
||||
const elem = await app.client.$(".clock .time");
|
||||
return elem.getText(".clock .time").toString().match(timeRegex);
|
||||
return testMatch(".clock .time", timeRegex);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -78,8 +80,7 @@ describe("Clock set to spanish language module", function () {
|
||||
|
||||
it("shows week with correct format", async function () {
|
||||
const weekRegex = /^Semana [0-9]{1,2}$/;
|
||||
const elem = await app.client.$(".clock .week");
|
||||
elem.getText(".clock .week").toString().match(weekRegex);
|
||||
return testMatch(".clock .week", weekRegex);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -6,6 +6,13 @@ describe("Clock module", function () {
|
||||
|
||||
let app = null;
|
||||
|
||||
testMatch = async function (element, regex) {
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
const elem = await app.client.$(element);
|
||||
const txt = await elem.getText(element);
|
||||
return txt.match(regex);
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
return helpers
|
||||
.startApplication({
|
||||
@@ -28,14 +35,12 @@ describe("Clock module", function () {
|
||||
|
||||
it("should show the date in the correct format", async function () {
|
||||
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 elem = await app.client.$(".clock .date");
|
||||
return elem.getText(".clock .date").toString().match(dateRegex);
|
||||
return testMatch(".clock .date", dateRegex);
|
||||
});
|
||||
|
||||
it("should show the time in 24hr format", async function () {
|
||||
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
|
||||
const elem = await app.client.$(".clock .time");
|
||||
return elem.getText(".clock .time").toString().match(timeRegex);
|
||||
return testMatch(".clock .time", timeRegex);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -47,14 +52,12 @@ describe("Clock module", function () {
|
||||
|
||||
it("should show the date in the correct format", async function () {
|
||||
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 elem = await app.client.$(".clock .date");
|
||||
return elem.getText(".clock .date").toString().match(dateRegex);
|
||||
return testMatch(".clock .date", dateRegex);
|
||||
});
|
||||
|
||||
it("should show the time in 12hr format", async function () {
|
||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
||||
const elem = await app.client.$(".clock .time");
|
||||
return elem.getText(".clock .time").toString().match(timeRegex);
|
||||
return testMatch(".clock .time", timeRegex);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -66,8 +69,7 @@ describe("Clock module", function () {
|
||||
|
||||
it("should show 12hr time with upper case AM/PM", async function () {
|
||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
||||
const elem = await app.client.$(".clock .time");
|
||||
return elem.getText(".clock .time").toString().match(timeRegex);
|
||||
return testMatch(".clock .time", timeRegex);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -79,8 +81,7 @@ describe("Clock module", function () {
|
||||
|
||||
it("should show 12hr time without seconds am/pm", async function () {
|
||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
|
||||
const elem = await app.client.$(".clock .time");
|
||||
return elem.getText(".clock .time").toString().match(timeRegex);
|
||||
return testMatch(".clock .time", timeRegex);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -92,15 +93,16 @@ describe("Clock module", function () {
|
||||
|
||||
it("should show the week in the correct format", async function () {
|
||||
const weekRegex = /^Week [0-9]{1,2}$/;
|
||||
const elem = await app.client.$(".clock .week");
|
||||
return elem.getText(".clock .week").toString().match(weekRegex);
|
||||
return testMatch(".clock .week", weekRegex);
|
||||
});
|
||||
|
||||
it("should show the week with the correct number of week of year", async function () {
|
||||
const currentWeekNumber = moment().week();
|
||||
const weekToShow = "Week " + currentWeekNumber;
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
const elem = await app.client.$(".clock .week");
|
||||
return elem.getText(".clock .week") === weekToShow;
|
||||
const txt = await elem.getText(".clock .week");
|
||||
return txt === weekToShow;
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -1,11 +0,0 @@
|
||||
const Sequencer = require("@jest/test-sequencer").default;
|
||||
|
||||
class CustomSequencer extends Sequencer {
|
||||
sort(tests) {
|
||||
let copyTests = Array.from(tests);
|
||||
copyTests = copyTests.sort((testA, testB) => (testA.path > testB.path ? -1 : 1));
|
||||
return (copyTests = copyTests.sort((testA, testB) => (testA.path.includes("/modules/") ? 1 : -1)));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CustomSequencer;
|
Reference in New Issue
Block a user