@@ -29,62 +29,62 @@ describe('MatList', () => {
29
29
} ) ) ;
30
30
31
31
it ( 'should not apply any additional class to a list without lines' , ( ) => {
32
- let fixture = TestBed . createComponent ( ListWithOneItem ) ;
33
- let listItem = fixture . debugElement . query ( By . css ( 'mat-list-item' ) ) ;
32
+ const fixture = TestBed . createComponent ( ListWithOneItem ) ;
33
+ const listItem = fixture . debugElement . query ( By . css ( 'mat-list-item' ) ) ;
34
34
fixture . detectChanges ( ) ;
35
35
expect ( listItem . nativeElement . className ) . toBe ( 'mat-list-item' ) ;
36
36
} ) ;
37
37
38
38
it ( 'should apply mat-2-line class to lists with two lines' , ( ) => {
39
- let fixture = TestBed . createComponent ( ListWithTwoLineItem ) ;
39
+ const fixture = TestBed . createComponent ( ListWithTwoLineItem ) ;
40
40
fixture . detectChanges ( ) ;
41
41
42
- let listItems = fixture . debugElement . children [ 0 ] . queryAll ( By . css ( 'mat-list-item' ) ) ;
42
+ const listItems = fixture . debugElement . children [ 0 ] . queryAll ( By . css ( 'mat-list-item' ) ) ;
43
43
expect ( listItems [ 0 ] . nativeElement . className ) . toContain ( 'mat-2-line' ) ;
44
44
expect ( listItems [ 1 ] . nativeElement . className ) . toContain ( 'mat-2-line' ) ;
45
45
} ) ;
46
46
47
47
it ( 'should apply mat-3-line class to lists with three lines' , ( ) => {
48
- let fixture = TestBed . createComponent ( ListWithThreeLineItem ) ;
48
+ const fixture = TestBed . createComponent ( ListWithThreeLineItem ) ;
49
49
fixture . detectChanges ( ) ;
50
50
51
- let listItems = fixture . debugElement . children [ 0 ] . queryAll ( By . css ( 'mat-list-item' ) ) ;
51
+ const listItems = fixture . debugElement . children [ 0 ] . queryAll ( By . css ( 'mat-list-item' ) ) ;
52
52
expect ( listItems [ 0 ] . nativeElement . className ) . toContain ( 'mat-3-line' ) ;
53
53
expect ( listItems [ 1 ] . nativeElement . className ) . toContain ( 'mat-3-line' ) ;
54
54
} ) ;
55
55
56
56
it ( 'should apply mat-multi-line class to lists with more than 3 lines' , ( ) => {
57
- let fixture = TestBed . createComponent ( ListWithManyLines ) ;
57
+ const fixture = TestBed . createComponent ( ListWithManyLines ) ;
58
58
fixture . detectChanges ( ) ;
59
59
60
- let listItems = fixture . debugElement . children [ 0 ] . queryAll ( By . css ( 'mat-list-item' ) ) ;
60
+ const listItems = fixture . debugElement . children [ 0 ] . queryAll ( By . css ( 'mat-list-item' ) ) ;
61
61
expect ( listItems [ 0 ] . nativeElement . className ) . toContain ( 'mat-multi-line' ) ;
62
62
expect ( listItems [ 1 ] . nativeElement . className ) . toContain ( 'mat-multi-line' ) ;
63
63
} ) ;
64
64
65
65
it ( 'should apply a class to list items with avatars' , ( ) => {
66
- let fixture = TestBed . createComponent ( ListWithAvatar ) ;
66
+ const fixture = TestBed . createComponent ( ListWithAvatar ) ;
67
67
fixture . detectChanges ( ) ;
68
68
69
- let listItems = fixture . debugElement . children [ 0 ] . queryAll ( By . css ( 'mat-list-item' ) ) ;
69
+ const listItems = fixture . debugElement . children [ 0 ] . queryAll ( By . css ( 'mat-list-item' ) ) ;
70
70
expect ( listItems [ 0 ] . nativeElement . className ) . toContain ( 'mat-list-item-with-avatar' ) ;
71
71
expect ( listItems [ 1 ] . nativeElement . className ) . not . toContain ( 'mat-list-item-with-avatar' ) ;
72
72
} ) ;
73
73
74
74
it ( 'should not clear custom classes provided by user' , ( ) => {
75
- let fixture = TestBed . createComponent ( ListWithItemWithCssClass ) ;
75
+ const fixture = TestBed . createComponent ( ListWithItemWithCssClass ) ;
76
76
fixture . detectChanges ( ) ;
77
77
78
- let listItems = fixture . debugElement . children [ 0 ] . queryAll ( By . css ( 'mat-list-item' ) ) ;
78
+ const listItems = fixture . debugElement . children [ 0 ] . queryAll ( By . css ( 'mat-list-item' ) ) ;
79
79
expect ( listItems [ 0 ] . nativeElement . classList . contains ( 'test-class' ) ) . toBe ( true ) ;
80
80
} ) ;
81
81
82
82
it ( 'should update classes if number of lines change' , ( ) => {
83
- let fixture = TestBed . createComponent ( ListWithDynamicNumberOfLines ) ;
83
+ const fixture = TestBed . createComponent ( ListWithDynamicNumberOfLines ) ;
84
84
fixture . debugElement . componentInstance . showThirdLine = false ;
85
85
fixture . detectChanges ( ) ;
86
86
87
- let listItem = fixture . debugElement . children [ 0 ] . query ( By . css ( 'mat-list-item' ) ) ;
87
+ const listItem = fixture . debugElement . children [ 0 ] . query ( By . css ( 'mat-list-item' ) ) ;
88
88
expect ( listItem . nativeElement . classList . length ) . toBe ( 2 ) ;
89
89
expect ( listItem . nativeElement . classList ) . toContain ( 'mat-2-line' ) ;
90
90
expect ( listItem . nativeElement . classList ) . toContain ( 'mat-list-item' ) ;
@@ -95,17 +95,17 @@ describe('MatList', () => {
95
95
} ) ;
96
96
97
97
it ( 'should add aria roles properly' , ( ) => {
98
- let fixture = TestBed . createComponent ( ListWithMultipleItems ) ;
98
+ const fixture = TestBed . createComponent ( ListWithMultipleItems ) ;
99
99
fixture . detectChanges ( ) ;
100
100
101
- let list = fixture . debugElement . children [ 0 ] ;
102
- let listItem = fixture . debugElement . children [ 0 ] . query ( By . css ( 'mat-list-item' ) ) ;
101
+ const list = fixture . debugElement . children [ 0 ] ;
102
+ const listItem = fixture . debugElement . children [ 0 ] . query ( By . css ( 'mat-list-item' ) ) ;
103
103
expect ( list . nativeElement . getAttribute ( 'role' ) ) . toBeNull ( 'Expect mat-list no role' ) ;
104
104
expect ( listItem . nativeElement . getAttribute ( 'role' ) ) . toBeNull ( 'Expect mat-list-item no role' ) ;
105
105
} ) ;
106
106
107
107
it ( 'should not show ripples for non-nav lists' , ( ) => {
108
- let fixture = TestBed . createComponent ( ListWithOneAnchorItem ) ;
108
+ const fixture = TestBed . createComponent ( ListWithOneAnchorItem ) ;
109
109
fixture . detectChanges ( ) ;
110
110
111
111
const items : QueryList < MatListItem > = fixture . debugElement . componentInstance . listItems ;
@@ -114,7 +114,7 @@ describe('MatList', () => {
114
114
} ) ;
115
115
116
116
it ( 'should allow disabling ripples for specific nav-list items' , ( ) => {
117
- let fixture = TestBed . createComponent ( NavListWithOneAnchorItem ) ;
117
+ const fixture = TestBed . createComponent ( NavListWithOneAnchorItem ) ;
118
118
fixture . detectChanges ( ) ;
119
119
120
120
const items = fixture . componentInstance . listItems ;
@@ -137,6 +137,29 @@ describe('MatList', () => {
137
137
expect ( items . length ) . toBeGreaterThan ( 0 ) ;
138
138
} ) ;
139
139
140
+ it ( 'should enable ripples for action lists by default' , ( ) => {
141
+ const fixture = TestBed . createComponent ( ActionListWithoutType ) ;
142
+ fixture . detectChanges ( ) ;
143
+
144
+ const items = fixture . componentInstance . listItems ;
145
+ expect ( items . toArray ( ) . every ( item => ! item . _isRippleDisabled ( ) ) ) . toBe ( true ) ;
146
+ } ) ;
147
+
148
+ it ( 'should allow disabling ripples for specific action list items' , ( ) => {
149
+ const fixture = TestBed . createComponent ( ActionListWithoutType ) ;
150
+ fixture . detectChanges ( ) ;
151
+
152
+ const items = fixture . componentInstance . listItems . toArray ( ) ;
153
+ expect ( items . length ) . toBeGreaterThan ( 0 ) ;
154
+
155
+ expect ( items . every ( item => ! item . _isRippleDisabled ( ) ) ) . toBe ( true ) ;
156
+
157
+ fixture . componentInstance . disableItemRipple = true ;
158
+ fixture . detectChanges ( ) ;
159
+
160
+ expect ( items . every ( item => item . _isRippleDisabled ( ) ) ) . toBe ( true ) ;
161
+ } ) ;
162
+
140
163
it ( 'should set default type attribute to button for action list' , ( ) => {
141
164
const fixture = TestBed . createComponent ( ActionListWithoutType ) ;
142
165
fixture . detectChanges ( ) ;
@@ -154,7 +177,7 @@ describe('MatList', () => {
154
177
} ) ;
155
178
156
179
it ( 'should allow disabling ripples for the whole nav-list' , ( ) => {
157
- let fixture = TestBed . createComponent ( NavListWithOneAnchorItem ) ;
180
+ const fixture = TestBed . createComponent ( NavListWithOneAnchorItem ) ;
158
181
fixture . detectChanges ( ) ;
159
182
160
183
const items = fixture . componentInstance . listItems ;
@@ -168,6 +191,22 @@ describe('MatList', () => {
168
191
169
192
items . forEach ( item => expect ( item . _isRippleDisabled ( ) ) . toBe ( true ) ) ;
170
193
} ) ;
194
+
195
+ it ( 'should allow disabling ripples for the entire action list' , ( ) => {
196
+ const fixture = TestBed . createComponent ( ActionListWithoutType ) ;
197
+ fixture . detectChanges ( ) ;
198
+
199
+ const items = fixture . componentInstance . listItems . toArray ( ) ;
200
+ expect ( items . length ) . toBeGreaterThan ( 0 ) ;
201
+
202
+ expect ( items . every ( item => ! item . _isRippleDisabled ( ) ) ) . toBe ( true ) ;
203
+
204
+ fixture . componentInstance . disableListRipple = true ;
205
+ fixture . detectChanges ( ) ;
206
+
207
+ expect ( items . every ( item => item . _isRippleDisabled ( ) ) ) . toBe ( true ) ;
208
+ } ) ;
209
+
171
210
} ) ;
172
211
173
212
@@ -205,13 +244,15 @@ class NavListWithOneAnchorItem extends BaseTestList {
205
244
}
206
245
207
246
@Component ( { template : `
208
- <mat-action-list>
209
- <button mat-list-item>
247
+ <mat-action-list [disableRipple]="disableListRipple" >
248
+ <button mat-list-item [disableRipple]="disableItemRipple" >
210
249
Paprika
211
250
</button>
212
251
</mat-action-list>` } )
213
252
class ActionListWithoutType extends BaseTestList {
214
253
@ViewChildren ( MatListItem ) listItems : QueryList < MatListItem > ;
254
+ disableListRipple = false ;
255
+ disableItemRipple = false ;
215
256
}
216
257
217
258
@Component ( { template : `
0 commit comments