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