@@ -47,9 +47,43 @@ describe('MatCalendarBody', () => {
47
47
} ) ;
48
48
49
49
it ( 'highlights today' , ( ) => {
50
- const todayCell = calendarBodyNativeElement . querySelector ( '.mat-calendar-body-today' ) ! ;
50
+ const todayCells = calendarBodyNativeElement . querySelectorAll ( '.mat-calendar-body-today' ) ! ;
51
+ expect ( todayCells . length ) . toBe ( 1 ) ;
52
+
53
+ const todayCell = todayCells [ 0 ] ;
54
+
51
55
expect ( todayCell ) . not . toBeNull ( ) ;
52
- expect ( todayCell . innerHTML . trim ( ) ) . toBe ( '3' ) ;
56
+ expect ( todayCell . textContent ! . trim ( ) ) . toBe ( '3' ) ;
57
+ } ) ;
58
+
59
+ it ( 'sets aria-current="date" on today' , ( ) => {
60
+ const todayCells = calendarBodyNativeElement . querySelectorAll (
61
+ '[aria-current="date"] .mat-calendar-body-today' ,
62
+ ) ! ;
63
+ expect ( todayCells . length ) . toBe ( 1 ) ;
64
+
65
+ const todayCell = todayCells [ 0 ] ;
66
+
67
+ expect ( todayCell ) . not . toBeNull ( ) ;
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 ' + 'the scope' , ( ) => {
80
+ testComponent . todayValue = 100000 ;
81
+ fixture . detectChanges ( ) ;
82
+
83
+ const todayCell = calendarBodyNativeElement . querySelector (
84
+ '[aria-current="date"] .mat-calendar-body-today' ,
85
+ ) ! ;
86
+ expect ( todayCell ) . toBeNull ( ) ;
53
87
} ) ;
54
88
55
89
it ( 'highlights selected' , ( ) => {
0 commit comments