@@ -1538,13 +1538,36 @@ describe('MatDatepicker', () => {
15381538 } ) ;
15391539 } ) ;
15401540
1541- describe ( 'datepicker toggle without a datepicker' , ( ) => {
1541+ describe ( 'datepicker directives without a datepicker' , ( ) => {
15421542 it ( 'should not throw on init if toggle does not have a datepicker' , ( ) => {
15431543 expect ( ( ) => {
15441544 const fixture = createComponent ( DatepickerToggleWithNoDatepicker , [ MatNativeDateModule ] ) ;
15451545 fixture . detectChanges ( ) ;
15461546 } ) . not . toThrow ( ) ;
15471547 } ) ;
1548+
1549+ it ( 'should not set aria-haspopup if toggle does not have a datepicker' , ( ) => {
1550+ const fixture = createComponent ( DatepickerToggleWithNoDatepicker , [ MatNativeDateModule ] ) ;
1551+ fixture . detectChanges ( ) ;
1552+ const toggle = fixture . nativeElement . querySelector ( '.mat-datepicker-toggle button' ) ;
1553+
1554+ expect ( toggle . hasAttribute ( 'aria-haspopup' ) ) . toBe ( false ) ;
1555+ } ) ;
1556+
1557+ it ( 'should not throw on init if input does not have a datepicker' , ( ) => {
1558+ expect ( ( ) => {
1559+ const fixture = createComponent ( DatepickerInputWithNoDatepicker , [ MatNativeDateModule ] ) ;
1560+ fixture . detectChanges ( ) ;
1561+ } ) . not . toThrow ( ) ;
1562+ } ) ;
1563+
1564+ it ( 'should not set aria-haspopup if input does not have a datepicker' , ( ) => {
1565+ const fixture = createComponent ( DatepickerInputWithNoDatepicker , [ MatNativeDateModule ] ) ;
1566+ fixture . detectChanges ( ) ;
1567+ const toggle = fixture . nativeElement . querySelector ( 'input' ) ;
1568+
1569+ expect ( toggle . hasAttribute ( 'aria-haspopup' ) ) . toBe ( false ) ;
1570+ } ) ;
15481571 } ) ;
15491572
15501573 describe ( 'popup positioning' , ( ) => {
@@ -1990,3 +2013,10 @@ class DatepickerWithTabindexOnToggle {}
19902013 ` ,
19912014} )
19922015class DatepickerToggleWithNoDatepicker { }
2016+
2017+ @Component ( {
2018+ template : `
2019+ <input [matDatepicker]="d">
2020+ ` ,
2021+ } )
2022+ class DatepickerInputWithNoDatepicker { }
0 commit comments