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