MagicMirror/tests/e2e/modules/clock_es_spec.js

91 lines
3.1 KiB
JavaScript
Raw Normal View History

const helpers = require("../global-setup");
const describe = global.describe;
const it = global.it;
const beforeEach = global.beforeEach;
const afterEach = global.afterEach;
describe("Clock set to spanish language module", function () {
helpers.setupTimeout(this);
var app = null;
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function () {
return helpers.stopApplication(app);
});
describe("with default 24hr clock config", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_24hr.js";
});
2021-01-30 20:29:59 +01:00
it("shows date with correct format", async function () {
2021-02-06 23:52:44 +01:00
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}$/;
2021-01-30 20:29:59 +01:00
const elem = await app.client.$(".clock .date");
return elem.getText(".clock .date").should.eventually.match(dateRegex);
});
2021-01-30 20:29:59 +01:00
it("shows time in 24hr format", async function () {
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
2021-01-30 20:29:59 +01:00
const elem = await app.client.$(".clock .time");
return elem.getText(".clock .time").should.eventually.match(timeRegex);
});
});
describe("with default 12hr clock config", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_12hr.js";
});
2021-01-30 20:29:59 +01:00
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}$/;
2021-01-30 20:29:59 +01:00
const elem = await app.client.$(".clock .date");
return elem.getText(".clock .date").should.eventually.match(dateRegex);
});
2021-01-30 20:29:59 +01:00
it("shows time in 12hr format", async function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
2021-01-30 20:29:59 +01:00
const elem = await app.client.$(".clock .time");
return elem.getText(".clock .time").should.eventually.match(timeRegex);
});
});
describe("with showPeriodUpper config enabled", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_showPeriodUpper.js";
});
2021-01-30 20:29:59 +01:00
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$/;
2021-01-30 20:29:59 +01:00
const elem = await app.client.$(".clock .time");
return elem.getText(".clock .time").should.eventually.match(timeRegex);
});
});
describe("with showWeek config enabled", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_showWeek.js";
});
2021-01-30 20:29:59 +01:00
it("shows week with correct format", async function () {
const weekRegex = /^Semana [0-9]{1,2}$/;
2021-01-30 20:29:59 +01:00
const elem = await app.client.$(".clock .week");
elem.getText(".clock .week").should.eventually.match(weekRegex);
});
});
});