@@ -20,7 +20,8 @@ describe('MatList', () => {
2020 ListWithMultipleItems ,
2121 ListWithManyLines ,
2222 NavListWithOneAnchorItem ,
23- ActionListWithOneItem
23+ ActionListWithoutType ,
24+ ActionListWithType
2425 ] ,
2526 } ) ;
2627
@@ -146,13 +147,29 @@ describe('MatList', () => {
146147 } ) ;
147148
148149 it ( 'should create an action list' , ( ) => {
149- let fixture = TestBed . createComponent ( ActionListWithOneItem ) ;
150+ const fixture = TestBed . createComponent ( ActionListWithoutType ) ;
150151 fixture . detectChanges ( ) ;
151152
152153 const items = fixture . componentInstance . listItems ;
153154 expect ( items . length ) . toBeGreaterThan ( 0 ) ;
154155 } ) ;
155156
157+ it ( 'should set default type attribute to button for action list' , ( ) => {
158+ const fixture = TestBed . createComponent ( ActionListWithoutType ) ;
159+ fixture . detectChanges ( ) ;
160+
161+ const listItemEl = fixture . debugElement . query ( By . css ( '.mat-list-item' ) ) ;
162+ expect ( listItemEl . nativeElement . getAttribute ( 'type' ) ) . toBe ( 'button' ) ;
163+ } ) ;
164+
165+ it ( 'should not change type attribute if it is already specified' , ( ) => {
166+ const fixture = TestBed . createComponent ( ActionListWithType ) ;
167+ fixture . detectChanges ( ) ;
168+
169+ const listItemEl = fixture . debugElement . query ( By . css ( '.mat-list-item' ) ) ;
170+ expect ( listItemEl . nativeElement . getAttribute ( 'type' ) ) . toBe ( 'submit' ) ;
171+ } ) ;
172+
156173 it ( 'should allow disabling ripples for the whole nav-list' , ( ) => {
157174 let fixture = TestBed . createComponent ( NavListWithOneAnchorItem ) ;
158175 fixture . detectChanges ( ) ;
@@ -210,7 +227,17 @@ class NavListWithOneAnchorItem extends BaseTestList {
210227 Paprika
211228 </button>
212229 </mat-action-list>` } )
213- class ActionListWithOneItem extends BaseTestList {
230+ class ActionListWithoutType extends BaseTestList {
231+ @ViewChildren ( MatListItem ) listItems : QueryList < MatListItem > ;
232+ }
233+
234+ @Component ( { template : `
235+ <mat-action-list>
236+ <button mat-list-item type="submit">
237+ Paprika
238+ </button>
239+ </mat-action-list>` } )
240+ class ActionListWithType extends BaseTestList {
214241 @ViewChildren ( MatListItem ) listItems : QueryList < MatListItem > ;
215242}
216243
0 commit comments