@@ -1202,6 +1202,56 @@ describe("Month", () => {
12021202 } ) ;
12031203
12041204 it ( "should have no axe violations" , ( ) => runAxe ( monthComponent ) ) ;
1205+
1206+ it ( "should apply the selected class when the quarter is a part of selected date" , ( ) => {
1207+ const selectedDate = newDate ( "2025-11-01" ) ;
1208+ const keyboardSelectedDate = selectedDate ;
1209+
1210+ const { container } = render (
1211+ < Month
1212+ day = { selectedDate }
1213+ selected = { selectedDate }
1214+ preSelection = { keyboardSelectedDate }
1215+ showQuarterYearPicker
1216+ /> ,
1217+ ) ;
1218+
1219+ const selected = container . querySelector (
1220+ ".react-datepicker__quarter-text--selected" ,
1221+ ) ;
1222+ expect ( selected ) . not . toBeNull ( ) ;
1223+ expect ( selected ?. textContent ) . toBe ( "Q4" ) ;
1224+ } ) ;
1225+
1226+ it ( "should apply the selected class when the quarter is a part of selected dates" , ( ) => {
1227+ const selectedDates = [ newDate ( "2025-11-01" ) , newDate ( "2025-01-01" ) ] ;
1228+ const keyboardSelectedDate = selectedDates [ 0 ] ;
1229+ const day = selectedDates [ 0 ] as Date ;
1230+
1231+ const { container } = render (
1232+ < Month
1233+ day = { day }
1234+ selectedDates = { selectedDates }
1235+ preSelection = { keyboardSelectedDate }
1236+ selectsMultiple
1237+ showQuarterYearPicker
1238+ /> ,
1239+ ) ;
1240+
1241+ const selectedElements = Array . from (
1242+ container . querySelectorAll ( ".react-datepicker__quarter-text--selected" ) ,
1243+ ) ;
1244+ expect ( selectedElements . length ) . toBe ( selectedDates . length ) ;
1245+
1246+ const expectedQuarterLabels = selectedDates . map (
1247+ ( date ) => `Q${ getQuarter ( date ) } ` ,
1248+ ) ;
1249+ expect (
1250+ expectedQuarterLabels . every ( ( label ) =>
1251+ selectedElements . some ( ( element ) => element ?. textContent === label ) ,
1252+ ) ,
1253+ ) . toBe ( true ) ;
1254+ } ) ;
12051255 } ) ;
12061256
12071257 describe ( "if quarter is not selected" , ( ) => {
@@ -2653,6 +2703,32 @@ describe("Month", () => {
26532703 expect ( selected ) . not . toBeNull ( ) ;
26542704 expect ( keyboardSelected ) . toBeNull ( ) ;
26552705 } ) ;
2706+
2707+ it ( "should not apply the keyboard-selected class when the quarter is a part of selected dates" , ( ) => {
2708+ const selectedDates = [ newDate ( "2025-11-01" ) ] ;
2709+ const keyboardSelectedDate = selectedDates [ 0 ] ;
2710+ const day = selectedDates [ 0 ] as Date ;
2711+
2712+ const { container } = render (
2713+ < Month
2714+ day = { day }
2715+ selectedDates = { selectedDates }
2716+ preSelection = { keyboardSelectedDate }
2717+ selectsMultiple
2718+ showQuarterYearPicker
2719+ /> ,
2720+ ) ;
2721+
2722+ const selected = container . querySelector (
2723+ ".react-datepicker__quarter-text--selected" ,
2724+ ) ;
2725+ const keyboardSelected = container . querySelector (
2726+ ".react-datepicker__quarter-text--keyboard-selected" ,
2727+ ) ;
2728+
2729+ expect ( selected ) . not . toBeNull ( ) ;
2730+ expect ( keyboardSelected ) . toBeNull ( ) ;
2731+ } ) ;
26562732 } ) ;
26572733
26582734 describe ( "Auto-Focus" , ( ) => {
0 commit comments