@@ -47,9 +47,43 @@ describe('MatCalendarBody', () => {
4747 } ) ;
4848
4949 it ( 'highlights today' , ( ) => {
50- const todayCell = calendarBodyNativeElement . querySelector ( '.mat-calendar-body-today' ) ! ;
50+ const todayCells = calendarBodyNativeElement . querySelectorAll (
51+ '.mat-calendar-body-today' ) ! ;
52+ expect ( todayCells . length ) . toBe ( 1 ) ;
53+
54+ const todayCell = todayCells [ 0 ] ;
55+
56+ expect ( todayCell ) . not . toBeNull ( ) ;
57+ expect ( todayCell . textContent ! . trim ( ) ) . toBe ( '3' ) ;
58+ } ) ;
59+
60+ it ( 'sets aria-current="date" on today' , ( ) => {
61+ const todayCells = calendarBodyNativeElement . querySelectorAll (
62+ '[aria-current="date"] .mat-calendar-body-today' ) ! ;
63+ expect ( todayCells . length ) . toBe ( 1 ) ;
64+
65+ const todayCell = todayCells [ 0 ] ;
66+
5167 expect ( todayCell ) . not . toBeNull ( ) ;
52- expect ( todayCell . innerHTML . trim ( ) ) . toBe ( '3' ) ;
68+ expect ( todayCell . textContent ! . trim ( ) ) . toBe ( '3' ) ;
69+ } ) ;
70+
71+ it ( 'does not highlight today if today is not within the scope' , ( ) => {
72+ testComponent . todayValue = 100000 ;
73+ fixture . detectChanges ( ) ;
74+
75+ const todayCell = calendarBodyNativeElement . querySelector ( '.mat-calendar-body-today' ) ! ;
76+ expect ( todayCell ) . toBeNull ( ) ;
77+ } ) ;
78+
79+ it ( 'does not set aria-current="date" on any cell if today is not ' +
80+ 'the scope' , ( ) => {
81+ testComponent . todayValue = 100000 ;
82+ fixture . detectChanges ( ) ;
83+
84+ const todayCell = calendarBodyNativeElement . querySelector (
85+ '[aria-current="date"] .mat-calendar-body-today' ) ! ;
86+ expect ( todayCell ) . toBeNull ( ) ;
5387 } ) ;
5488
5589 it ( 'highlights selected' , ( ) => {
0 commit comments