2026-01-01 08:45:36 -06:00
const { expect } = require ( "playwright/test" );
2023-01-01 18:09:08 +01:00
const helpers = require ( "../helpers/global-setup" );
2021-09-26 22:09:41 +02:00
2022-09-20 23:43:06 +02:00
describe ( "Clock set to spanish language module" , () => {
2026-01-01 08:45:36 -06:00
let page ;
2022-09-20 23:43:06 +02:00
afterAll ( async () => {
2022-05-27 19:46:28 +02:00
await helpers . stopApplication ();
2021-09-26 22:09:41 +02:00
});
2022-09-20 23:43:06 +02:00
describe ( "with default 24hr clock config" , () => {
2023-01-01 18:09:08 +01:00
beforeAll ( async () => {
await helpers . startApplication ( "tests/configs/modules/clock/es/clock_24hr.js" );
await helpers . getDocument ();
2026-01-01 08:45:36 -06:00
page = helpers . getPage ();
2021-09-26 22:09:41 +02:00
});
2023-01-01 18:09:08 +01: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}$/ ;
2026-01-01 08:45:36 -06:00
await expect ( page . locator ( ".clock .date" )). toHaveText ( dateRegex );
2021-09-26 22:09:41 +02:00
});
2023-01-01 18:09:08 +01: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$/ ;
2026-01-01 08:45:36 -06:00
await expect ( page . locator ( ".clock .time" )). toHaveText ( timeRegex );
2021-09-26 22:09:41 +02:00
});
});
2022-09-20 23:43:06 +02:00
describe ( "with default 12hr clock config" , () => {
2023-01-01 18:09:08 +01:00
beforeAll ( async () => {
await helpers . startApplication ( "tests/configs/modules/clock/es/clock_12hr.js" );
await helpers . getDocument ();
2026-01-01 08:45:36 -06:00
page = helpers . getPage ();
2021-09-26 22:09:41 +02:00
});
2023-01-01 18:09:08 +01: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}$/ ;
2026-01-01 08:45:36 -06:00
await expect ( page . locator ( ".clock .date" )). toHaveText ( dateRegex );
2021-09-26 22:09:41 +02:00
});
2023-01-01 18:09:08 +01: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$/ ;
2026-01-01 08:45:36 -06:00
await expect ( page . locator ( ".clock .time" )). toHaveText ( timeRegex );
2021-09-26 22:09:41 +02:00
});
});
2022-09-20 23:43:06 +02:00
describe ( "with showPeriodUpper config enabled" , () => {
2023-01-01 18:09:08 +01:00
beforeAll ( async () => {
await helpers . startApplication ( "tests/configs/modules/clock/es/clock_showPeriodUpper.js" );
await helpers . getDocument ();
2026-01-01 08:45:36 -06:00
page = helpers . getPage ();
2021-09-26 22:09:41 +02:00
});
2023-01-01 18:09:08 +01: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$/ ;
2026-01-01 08:45:36 -06:00
await expect ( page . locator ( ".clock .time" )). toHaveText ( timeRegex );
2021-09-26 22:09:41 +02:00
});
});
2022-09-20 23:43:06 +02:00
describe ( "with showWeek config enabled" , () => {
2023-01-01 18:09:08 +01:00
beforeAll ( async () => {
await helpers . startApplication ( "tests/configs/modules/clock/es/clock_showWeek.js" );
await helpers . getDocument ();
2026-01-01 08:45:36 -06:00
page = helpers . getPage ();
2021-09-26 22:09:41 +02:00
});
2023-01-01 18:09:08 +01:00
it ( "shows week with correct format" , async () => {
2021-09-26 22:09:41 +02:00
const weekRegex = /^Semana [0-9]{1,2}$/ ;
2026-01-01 08:45:36 -06:00
await expect ( page . locator ( ".clock .week" )). toHaveText ( weekRegex );
2021-09-26 22:09:41 +02:00
});
});
2025-07-01 00:10:47 +02:00
describe ( "with showWeek short config enabled" , () => {
beforeAll ( async () => {
await helpers . startApplication ( "tests/configs/modules/clock/es/clock_showWeek_short.js" );
await helpers . getDocument ();
2026-01-01 08:45:36 -06:00
page = helpers . getPage ();
2025-07-01 00:10:47 +02:00
});
it ( "shows week with correct format" , async () => {
const weekRegex = /^S[0-9]{1,2}$/ ;
2026-01-01 08:45:36 -06:00
await expect ( page . locator ( ".clock .week" )). toHaveText ( weekRegex );
2025-07-01 00:10:47 +02:00
});
});
2021-09-26 22:09:41 +02:00
});