update clock tests, remove testSequencer

This commit is contained in:
Karsten Hassel
2021-06-14 17:02:11 +02:00
parent a2083be76b
commit ee23c5f72c
4 changed files with 30 additions and 40 deletions

View File

@@ -93,7 +93,6 @@
}, },
"jest": { "jest": {
"verbose": true, "verbose": true,
"testSequencer": "<rootDir>/tests/e2e/testSequencer.js",
"projects": [ "projects": [
{ {
"displayName": "unit", "displayName": "unit",
@@ -120,7 +119,6 @@
], ],
"testPathIgnorePatterns": [ "testPathIgnorePatterns": [
"<rootDir>/tests/e2e/modules/mocks", "<rootDir>/tests/e2e/modules/mocks",
"<rootDir>/tests/e2e/testSequencer.js",
"<rootDir>/tests/e2e/global-setup.js" "<rootDir>/tests/e2e/global-setup.js"
] ]
} }

View File

@@ -5,6 +5,13 @@ describe("Clock set to spanish language module", function () {
let app = null; 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 () { beforeEach(function () {
return helpers return helpers
.startApplication({ .startApplication({
@@ -27,14 +34,12 @@ describe("Clock set to spanish language module", function () {
it("shows date with correct format", async 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 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 testMatch(".clock .date", dateRegex);
return elem.getText(".clock .date").toString().match(dateRegex);
}); });
it("shows time in 24hr format", async function () { it("shows time in 24hr format", async function () {
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$/;
const elem = await app.client.$(".clock .time"); return testMatch(".clock .time", timeRegex);
return elem.getText(".clock .time").toString().match(timeRegex);
}); });
}); });
@@ -46,14 +51,12 @@ describe("Clock set to spanish language module", function () {
it("shows date with correct format", async 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 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 testMatch(".clock .date", dateRegex);
return elem.getText(".clock .date").toString().match(dateRegex);
}); });
it("shows time in 12hr format", async function () { it("shows time in 12hr format", async function () {
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$/;
const elem = await app.client.$(".clock .time"); return testMatch(".clock .time", timeRegex);
return elem.getText(".clock .time").toString().match(timeRegex);
}); });
}); });
@@ -65,8 +68,7 @@ describe("Clock set to spanish language module", function () {
it("shows 12hr time with upper case AM/PM", async 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 timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
const elem = await app.client.$(".clock .time"); return testMatch(".clock .time", timeRegex);
return elem.getText(".clock .time").toString().match(timeRegex);
}); });
}); });
@@ -78,8 +80,7 @@ describe("Clock set to spanish language module", function () {
it("shows week with correct format", async function () { it("shows week with correct format", async function () {
const weekRegex = /^Semana [0-9]{1,2}$/; const weekRegex = /^Semana [0-9]{1,2}$/;
const elem = await app.client.$(".clock .week"); return testMatch(".clock .week", weekRegex);
elem.getText(".clock .week").toString().match(weekRegex);
}); });
}); });
}); });

View File

@@ -6,6 +6,13 @@ describe("Clock module", function () {
let app = null; 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 () { beforeEach(function () {
return helpers return helpers
.startApplication({ .startApplication({
@@ -28,14 +35,12 @@ describe("Clock module", function () {
it("should show the date in the correct format", async 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 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 testMatch(".clock .date", dateRegex);
return elem.getText(".clock .date").toString().match(dateRegex);
}); });
it("should show the time in 24hr format", async function () { it("should show the time in 24hr format", async function () {
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$/;
const elem = await app.client.$(".clock .time"); return testMatch(".clock .time", timeRegex);
return elem.getText(".clock .time").toString().match(timeRegex);
}); });
}); });
@@ -47,14 +52,12 @@ describe("Clock module", function () {
it("should show the date in the correct format", async 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 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 testMatch(".clock .date", dateRegex);
return elem.getText(".clock .date").toString().match(dateRegex);
}); });
it("should show the time in 12hr format", async function () { 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 timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
const elem = await app.client.$(".clock .time"); return testMatch(".clock .time", timeRegex);
return elem.getText(".clock .time").toString().match(timeRegex);
}); });
}); });
@@ -66,8 +69,7 @@ describe("Clock module", function () {
it("should show 12hr time with upper case AM/PM", async 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 timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
const elem = await app.client.$(".clock .time"); return testMatch(".clock .time", timeRegex);
return elem.getText(".clock .time").toString().match(timeRegex);
}); });
}); });
@@ -79,8 +81,7 @@ describe("Clock module", function () {
it("should show 12hr time without seconds am/pm", async 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 timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
const elem = await app.client.$(".clock .time"); return testMatch(".clock .time", timeRegex);
return elem.getText(".clock .time").toString().match(timeRegex);
}); });
}); });
@@ -92,15 +93,16 @@ describe("Clock module", function () {
it("should show the week in the correct format", async function () { it("should show the week in the correct format", async function () {
const weekRegex = /^Week [0-9]{1,2}$/; const weekRegex = /^Week [0-9]{1,2}$/;
const elem = await app.client.$(".clock .week"); return testMatch(".clock .week", weekRegex);
return elem.getText(".clock .week").toString().match(weekRegex);
}); });
it("should show the week with the correct number of week of year", async function () { it("should show the week with the correct number of week of year", async function () {
const currentWeekNumber = moment().week(); const currentWeekNumber = moment().week();
const weekToShow = "Week " + currentWeekNumber; const weekToShow = "Week " + currentWeekNumber;
await app.client.waitUntilWindowLoaded();
const elem = await app.client.$(".clock .week"); const elem = await app.client.$(".clock .week");
return elem.getText(".clock .week") === weekToShow; const txt = await elem.getText(".clock .week");
return txt === weekToShow;
}); });
}); });

View File

@@ -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;