@@ -189,6 +189,39 @@ describe('MdDatepicker', () => {
189189 expect ( attachToRef . nativeElement . tagName . toLowerCase ( ) )
190190 . toBe ( 'input' , 'popup should be attached to native input' ) ;
191191 } ) ;
192+
193+ it ( 'input should aria-owns calendar after opened in non-touch mode' , ( ) => {
194+ let inputEl = fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement ;
195+ expect ( inputEl . getAttribute ( 'aria-owns' ) ) . toBeNull ( ) ;
196+
197+ testComponent . datepicker . open ( ) ;
198+ fixture . detectChanges ( ) ;
199+
200+ let ownedElementId = inputEl . getAttribute ( 'aria-owns' ) ;
201+ expect ( ownedElementId ) . not . toBeNull ( ) ;
202+
203+ let ownedElement = document . getElementById ( ownedElementId ) ;
204+ expect ( ownedElement ) . not . toBeNull ( ) ;
205+ expect ( ( ownedElement as Element ) . tagName . toLowerCase ( ) ) . toBe ( 'md-calendar' ) ;
206+ } ) ;
207+
208+ it ( 'input should aria-owns calendar after opened in touch mode' , ( ) => {
209+ testComponent . touch = true ;
210+ fixture . detectChanges ( ) ;
211+
212+ let inputEl = fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement ;
213+ expect ( inputEl . getAttribute ( 'aria-owns' ) ) . toBeNull ( ) ;
214+
215+ testComponent . datepicker . open ( ) ;
216+ fixture . detectChanges ( ) ;
217+
218+ let ownedElementId = inputEl . getAttribute ( 'aria-owns' ) ;
219+ expect ( ownedElementId ) . not . toBeNull ( ) ;
220+
221+ let ownedElement = document . getElementById ( ownedElementId ) ;
222+ expect ( ownedElement ) . not . toBeNull ( ) ;
223+ expect ( ( ownedElement as Element ) . tagName . toLowerCase ( ) ) . toBe ( 'md-calendar' ) ;
224+ } ) ;
192225 } ) ;
193226
194227 describe ( 'datepicker with too many inputs' , ( ) => {
0 commit comments