@@ -1539,13 +1539,36 @@ describe('MatDatepicker', () => {
1539
1539
} ) ;
1540
1540
} ) ;
1541
1541
1542
- describe ( 'datepicker toggle without a datepicker' , ( ) => {
1542
+ describe ( 'datepicker directives without a datepicker' , ( ) => {
1543
1543
it ( 'should not throw on init if toggle does not have a datepicker' , ( ) => {
1544
1544
expect ( ( ) => {
1545
1545
const fixture = createComponent ( DatepickerToggleWithNoDatepicker , [ MatNativeDateModule ] ) ;
1546
1546
fixture . detectChanges ( ) ;
1547
1547
} ) . not . toThrow ( ) ;
1548
1548
} ) ;
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
+ } ) ;
1549
1572
} ) ;
1550
1573
1551
1574
describe ( 'popup positioning' , ( ) => {
@@ -1991,3 +2014,10 @@ class DatepickerWithTabindexOnToggle {}
1991
2014
` ,
1992
2015
} )
1993
2016
class DatepickerToggleWithNoDatepicker { }
2017
+
2018
+ @Component ( {
2019
+ template : `
2020
+ <input [matDatepicker]="d">
2021
+ ` ,
2022
+ } )
2023
+ class DatepickerInputWithNoDatepicker { }
0 commit comments