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