@@ -18,6 +18,7 @@ describe('MatMultiYearView', () => {
1818
1919 // Test components.
2020 StandardMultiYearView ,
21+ MultiYearViewWithDateFilter ,
2122 ] ,
2223 } ) ;
2324
@@ -71,6 +72,27 @@ describe('MatMultiYearView', () => {
7172 expect ( cellEls [ 1 ] . classList ) . toContain ( 'mat-calendar-body-active' ) ;
7273 } ) ;
7374 } ) ;
75+
76+ describe ( 'multi year view with date filter' , ( ) => {
77+ let fixture : ComponentFixture < MultiYearViewWithDateFilter > ;
78+ let testComponent : MultiYearViewWithDateFilter ;
79+ let multiYearViewNativeElement : Element ;
80+
81+ beforeEach ( ( ) => {
82+ fixture = TestBed . createComponent ( MultiYearViewWithDateFilter ) ;
83+ fixture . detectChanges ( ) ;
84+
85+ const multiYearViewDebugElement = fixture . debugElement . query ( By . directive ( MatMultiYearView ) ) ;
86+ multiYearViewNativeElement = multiYearViewDebugElement . nativeElement ;
87+ testComponent = fixture . componentInstance ;
88+ } ) ;
89+
90+ it ( 'should disablex years with no enabled days' , ( ) => {
91+ const cells = multiYearViewNativeElement . querySelectorAll ( '.mat-calendar-body-cell' ) ;
92+ expect ( cells [ 0 ] . classList ) . not . toContain ( 'mat-calendar-body-disabled' ) ;
93+ expect ( cells [ 1 ] . classList ) . toContain ( 'mat-calendar-body-disabled' ) ;
94+ } ) ;
95+ } ) ;
7496} ) ;
7597
7698
@@ -84,3 +106,15 @@ class StandardMultiYearView {
84106
85107 @ViewChild ( MatYearView ) yearView : MatYearView < Date > ;
86108}
109+
110+ @Component ( {
111+ template : `
112+ <mat-multi-year-view [activeDate]="activeDate" [dateFilter]="dateFilter"></mat-multi-year-view>
113+ `
114+ } )
115+ class MultiYearViewWithDateFilter {
116+ activeDate = new Date ( 2017 , JAN , 1 ) ;
117+ dateFilter ( date : Date ) {
118+ return date . getFullYear ( ) !== 2017 ;
119+ }
120+ }
0 commit comments