@@ -6,6 +6,8 @@ import YearRangePicker from "../../src/YearRangePicker.js";
66import YearPicker from "../../src/YearPicker.js" ;
77import "@ui5/webcomponents-localization/dist/features/calendar/Islamic.js" ;
88import "@ui5/webcomponents-localization/dist/features/calendar/Gregorian.js" ;
9+ import { resetConfiguration } from "@ui5/webcomponents-base/dist/InitialConfiguration.js" ;
10+ import { getFirstDayOfWeek } from "@ui5/webcomponents-base/dist/config/FormatSettings.js" ;
911
1012const getDefaultCalendar = ( date : Date ) => {
1113 const calDate = new Date ( date ) ;
@@ -1434,3 +1436,40 @@ describe("Day Picker Tests", () => {
14341436 } ) ;
14351437 } ) ;
14361438} ) ;
1439+
1440+ describe ( "Calendar Global Configuration" , ( ) => {
1441+ it ( "Should respect firstDayOfWeek from global formatSettings configuration" , ( ) => {
1442+ const configurationObject = {
1443+ "formatSettings" : {
1444+ "firstDayOfWeek" : 6 // Saturday
1445+ }
1446+ } ;
1447+
1448+ cy . window ( )
1449+ . then ( $el => {
1450+ const scriptElement = $el . document . createElement ( "script" ) ;
1451+ scriptElement . type = "application/json" ;
1452+ scriptElement . setAttribute ( "data-ui5-config" , "true" ) ;
1453+ scriptElement . innerHTML = JSON . stringify ( configurationObject ) ;
1454+ $el . document . head . appendChild ( scriptElement ) ;
1455+ } ) ;
1456+
1457+ cy . wrap ( { resetConfiguration } )
1458+ . invoke ( "resetConfiguration" , true ) ;
1459+
1460+ cy . wrap ( { getFirstDayOfWeek } )
1461+ . invoke ( "getFirstDayOfWeek" )
1462+ . should ( "equal" , 6 ) ;
1463+
1464+ const date = new Date ( Date . UTC ( 2023 , 0 , 1 , 0 , 0 , 0 ) ) ; // January 1, 2023
1465+ cy . mount ( < Calendar id = "calendar1" timestamp = { date . valueOf ( ) / 1000 } calendarWeekNumbering = "Default" /> ) ;
1466+
1467+ cy . get < Calendar > ( "#calendar1" )
1468+ . shadow ( )
1469+ . find ( "[ui5-daypicker]" )
1470+ . shadow ( )
1471+ . find ( ".ui5-dp-firstday" )
1472+ . first ( )
1473+ . should ( "have.text" , "Sat" ) ;
1474+ } ) ;
1475+ } ) ;
0 commit comments