MagicMirror/tests/e2e/modules/clock_es_spec.js

66 lines
2.4 KiB
JavaScript
Raw Normal View History

const helpers = require("../helpers/global-setup");
2021-09-26 22:09:41 +02:00
describe("Clock set to spanish language module", () => {
afterAll(async () => {
await helpers.stopApplication();
2021-09-26 22:09:41 +02:00
});
describe("with default 24hr clock config", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/es/clock_24hr.js");
await helpers.getDocument();
2021-09-26 22:09:41 +02:00
});
it("shows date with correct format", async () => {
2021-09-26 22:09:41 +02: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}$/;
await expect(helpers.testMatch(".clock .date", dateRegex)).resolves.toBe(true);
2021-09-26 22:09:41 +02:00
});
it("shows time in 24hr format", async () => {
2021-09-26 22:09:41 +02:00
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
2021-09-26 22:09:41 +02:00
});
});
describe("with default 12hr clock config", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/es/clock_12hr.js");
await helpers.getDocument();
2021-09-26 22:09:41 +02:00
});
it("shows date with correct format", async () => {
2021-09-26 22:09:41 +02: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}$/;
await expect(helpers.testMatch(".clock .date", dateRegex)).resolves.toBe(true);
2021-09-26 22:09:41 +02:00
});
it("shows time in 12hr format", async () => {
2021-09-26 22:09:41 +02:00
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
2021-09-26 22:09:41 +02:00
});
});
describe("with showPeriodUpper config enabled", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/es/clock_showPeriodUpper.js");
await helpers.getDocument();
2021-09-26 22:09:41 +02:00
});
it("shows 12hr time with upper case AM/PM", async () => {
2021-09-26 22:09:41 +02:00
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
await expect(helpers.testMatch(".clock .time", timeRegex)).resolves.toBe(true);
2021-09-26 22:09:41 +02:00
});
});
describe("with showWeek config enabled", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/es/clock_showWeek.js");
await helpers.getDocument();
2021-09-26 22:09:41 +02:00
});
it("shows week with correct format", async () => {
2021-09-26 22:09:41 +02:00
const weekRegex = /^Semana [0-9]{1,2}$/;
await expect(helpers.testMatch(".clock .week", weekRegex)).resolves.toBe(true);
2021-09-26 22:09:41 +02:00
});
});
});