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