@@ -151,6 +151,91 @@ describe('MDC-based MatSlider' , () => {
151
151
} ) ;
152
152
} ) ;
153
153
154
+ describe ( 'disabled slider' , ( ) => {
155
+ let sliderInstance : MatSlider ;
156
+ let inputInstance : MatSliderThumb ;
157
+
158
+ beforeEach ( waitForAsync ( ( ) => {
159
+ const fixture = createComponent ( DisabledSlider ) ;
160
+ fixture . detectChanges ( ) ;
161
+ const sliderDebugElement = fixture . debugElement . query ( By . directive ( MatSlider ) ) ;
162
+ sliderInstance = sliderDebugElement . componentInstance ;
163
+ inputInstance = sliderInstance . _getInput ( Thumb . END ) ;
164
+ } ) ) ;
165
+
166
+ it ( 'should be disabled' , ( ) => {
167
+ expect ( sliderInstance . disabled ) . toBeTrue ( ) ;
168
+ } ) ;
169
+
170
+ it ( 'should have the disabled class on the root element' , ( ) => {
171
+ expect ( sliderInstance . _elementRef . nativeElement . classList ) . toContain ( 'mdc-slider--disabled' ) ;
172
+ } ) ;
173
+
174
+ it ( 'should set the disabled attribute on the input element' , ( ) => {
175
+ expect ( inputInstance . _hostElement . disabled ) . toBeTrue ( ) ;
176
+ } ) ;
177
+
178
+ it ( 'should not update the value on mousedown' , ( ) => {
179
+ setValueByClick ( sliderInstance , 19 , platform . IOS ) ;
180
+ expect ( inputInstance . value ) . toBe ( 0 ) ;
181
+ } ) ;
182
+
183
+ it ( 'should not update the value on a slide' , ( ) => {
184
+ slideToValue ( sliderInstance , 77 , Thumb . END , platform . IOS ) ;
185
+ expect ( inputInstance . value ) . toBe ( 0 ) ;
186
+ } ) ;
187
+ } ) ;
188
+
189
+ describe ( 'disabled range slider' , ( ) => {
190
+ let sliderInstance : MatSlider ;
191
+ let startInputInstance : MatSliderThumb ;
192
+ let endInputInstance : MatSliderThumb ;
193
+
194
+ beforeEach ( waitForAsync ( ( ) => {
195
+ const fixture = createComponent ( DisabledRangeSlider ) ;
196
+ fixture . detectChanges ( ) ;
197
+ const sliderDebugElement = fixture . debugElement . query ( By . directive ( MatSlider ) ) ;
198
+ sliderInstance = sliderDebugElement . componentInstance ;
199
+ startInputInstance = sliderInstance . _getInput ( Thumb . START ) ;
200
+ endInputInstance = sliderInstance . _getInput ( Thumb . END ) ;
201
+ } ) ) ;
202
+
203
+ it ( 'should be disabled' , ( ) => {
204
+ expect ( sliderInstance . disabled ) . toBeTrue ( ) ;
205
+ } ) ;
206
+
207
+ it ( 'should have the disabled class on the root element' , ( ) => {
208
+ expect ( sliderInstance . _elementRef . nativeElement . classList ) . toContain ( 'mdc-slider--disabled' ) ;
209
+ } ) ;
210
+
211
+ it ( 'should set the disabled attribute on the input elements' , ( ) => {
212
+ expect ( startInputInstance . _hostElement . disabled ) . toBeTrue ( ) ;
213
+ expect ( endInputInstance . _hostElement . disabled ) . toBeTrue ( ) ;
214
+ } ) ;
215
+
216
+ it ( 'should not update the start value on a slide' , ( ) => {
217
+ slideToValue ( sliderInstance , 19 , Thumb . START , platform . IOS ) ;
218
+ expect ( startInputInstance . value ) . toBe ( 0 ) ;
219
+ } ) ;
220
+
221
+ it ( 'should not update the end value on a slide' , ( ) => {
222
+ slideToValue ( sliderInstance , 27 , Thumb . END , platform . IOS ) ;
223
+ expect ( endInputInstance . value ) . toBe ( 100 ) ;
224
+ } ) ;
225
+
226
+ it ( 'should not update the start value on mousedown behind the start thumb' , ( ) => {
227
+ sliderInstance . _setValue ( 19 , Thumb . START ) ;
228
+ setValueByClick ( sliderInstance , 12 , platform . IOS ) ;
229
+ expect ( startInputInstance . value ) . toBe ( 19 ) ;
230
+ } ) ;
231
+
232
+ it ( 'should update the end value on mousedown in front of the end thumb' , ( ) => {
233
+ sliderInstance . _setValue ( 27 , Thumb . END ) ;
234
+ setValueByClick ( sliderInstance , 55 , platform . IOS ) ;
235
+ expect ( endInputInstance . value ) . toBe ( 27 ) ;
236
+ } ) ;
237
+ } ) ;
238
+
154
239
describe ( 'ripple states' , ( ) => {
155
240
let fixture : ComponentFixture < StandardSlider > ;
156
241
let inputInstance : MatSliderThumb ;
@@ -202,81 +287,81 @@ describe('MDC-based MatSlider' , () => {
202
287
}
203
288
204
289
it ( 'should show the hover ripple on mouseenter' , fakeAsync ( ( ) => {
205
- expect ( isRippleVisible ( 'hover' ) ) . toBe ( false ) ;
290
+ expect ( isRippleVisible ( 'hover' ) ) . toBeFalse ( ) ;
206
291
mouseenter ( ) ;
207
- expect ( isRippleVisible ( 'hover' ) ) . toBe ( true ) ;
292
+ expect ( isRippleVisible ( 'hover' ) ) . toBeTrue ( ) ;
208
293
} ) ) ;
209
294
210
295
it ( 'should hide the hover ripple on mouseleave' , fakeAsync ( ( ) => {
211
296
mouseenter ( ) ;
212
297
mouseleave ( ) ;
213
- expect ( isRippleVisible ( 'hover' ) ) . toBe ( false ) ;
298
+ expect ( isRippleVisible ( 'hover' ) ) . toBeFalse ( ) ;
214
299
} ) ) ;
215
300
216
301
it ( 'should show the focus ripple on pointerdown' , fakeAsync ( ( ) => {
217
- expect ( isRippleVisible ( 'focus' ) ) . toBe ( false ) ;
302
+ expect ( isRippleVisible ( 'focus' ) ) . toBeFalse ( ) ;
218
303
pointerdown ( ) ;
219
- expect ( isRippleVisible ( 'focus' ) ) . toBe ( true ) ;
304
+ expect ( isRippleVisible ( 'focus' ) ) . toBeTrue ( ) ;
220
305
} ) ) ;
221
306
222
307
it ( 'should continue to show the focus ripple on pointerup' , fakeAsync ( ( ) => {
223
308
pointerdown ( ) ;
224
309
pointerup ( ) ;
225
- expect ( isRippleVisible ( 'focus' ) ) . toBe ( true ) ;
310
+ expect ( isRippleVisible ( 'focus' ) ) . toBeTrue ( ) ;
226
311
} ) ) ;
227
312
228
313
it ( 'should hide the focus ripple on blur' , fakeAsync ( ( ) => {
229
314
pointerdown ( ) ;
230
315
pointerup ( ) ;
231
316
blur ( ) ;
232
- expect ( isRippleVisible ( 'focus' ) ) . toBe ( false ) ;
317
+ expect ( isRippleVisible ( 'focus' ) ) . toBeFalse ( ) ;
233
318
} ) ) ;
234
319
235
320
it ( 'should show the active ripple on pointerdown' , fakeAsync ( ( ) => {
236
- expect ( isRippleVisible ( 'active' ) ) . toBe ( false ) ;
321
+ expect ( isRippleVisible ( 'active' ) ) . toBeFalse ( ) ;
237
322
pointerdown ( ) ;
238
- expect ( isRippleVisible ( 'active' ) ) . toBe ( true ) ;
323
+ expect ( isRippleVisible ( 'active' ) ) . toBeTrue ( ) ;
239
324
} ) ) ;
240
325
241
326
it ( 'should hide the active ripple on pointerup' , fakeAsync ( ( ) => {
242
327
pointerdown ( ) ;
243
328
pointerup ( ) ;
244
- expect ( isRippleVisible ( 'active' ) ) . toBe ( false ) ;
329
+ expect ( isRippleVisible ( 'active' ) ) . toBeFalse ( ) ;
245
330
} ) ) ;
246
331
247
332
// Edge cases.
248
333
249
334
it ( 'should not show the hover ripple if the thumb is already focused' , fakeAsync ( ( ) => {
250
335
pointerdown ( ) ;
251
336
mouseenter ( ) ;
252
- expect ( isRippleVisible ( 'hover' ) ) . toBe ( false ) ;
337
+ expect ( isRippleVisible ( 'hover' ) ) . toBeFalse ( ) ;
253
338
} ) ) ;
254
339
255
340
it ( 'should hide the hover ripple if the thumb is focused' , fakeAsync ( ( ) => {
256
341
mouseenter ( ) ;
257
342
pointerdown ( ) ;
258
- expect ( isRippleVisible ( 'hover' ) ) . toBe ( false ) ;
343
+ expect ( isRippleVisible ( 'hover' ) ) . toBeFalse ( ) ;
259
344
} ) ) ;
260
345
261
346
it ( 'should not hide the focus ripple if the thumb is pressed' , fakeAsync ( ( ) => {
262
347
pointerdown ( ) ;
263
348
blur ( ) ;
264
- expect ( isRippleVisible ( 'focus' ) ) . toBe ( true ) ;
349
+ expect ( isRippleVisible ( 'focus' ) ) . toBeTrue ( ) ;
265
350
} ) ) ;
266
351
267
352
it ( 'should not hide the hover ripple on blur if the thumb is hovered' , fakeAsync ( ( ) => {
268
353
mouseenter ( ) ;
269
354
pointerdown ( ) ;
270
355
pointerup ( ) ;
271
356
blur ( ) ;
272
- expect ( isRippleVisible ( 'hover' ) ) . toBe ( true ) ;
357
+ expect ( isRippleVisible ( 'hover' ) ) . toBeTrue ( ) ;
273
358
} ) ) ;
274
359
275
360
it ( 'should hide the focus ripple on drag end if the thumb already lost focus' , fakeAsync ( ( ) => {
276
361
pointerdown ( ) ;
277
362
blur ( ) ;
278
363
pointerup ( ) ;
279
- expect ( isRippleVisible ( 'focus' ) ) . toBe ( false ) ;
364
+ expect ( isRippleVisible ( 'focus' ) ) . toBeFalse ( ) ;
280
365
} ) ) ;
281
366
} ) ;
282
367
} ) ;
@@ -301,6 +386,25 @@ class StandardSlider {}
301
386
} )
302
387
class StandardRangeSlider { }
303
388
389
+ @Component ( {
390
+ template : `
391
+ <mat-slider disabled>
392
+ <input matSliderThumb>
393
+ </mat-slider>
394
+ ` ,
395
+ } )
396
+ class DisabledSlider { }
397
+
398
+ @Component ( {
399
+ template : `
400
+ <mat-slider disabled>
401
+ <input matSliderStartThumb>
402
+ <input matSliderEndThumb>
403
+ </mat-slider>
404
+ ` ,
405
+ } )
406
+ class DisabledRangeSlider { }
407
+
304
408
/** The pointer event types used by the MDC Slider. */
305
409
const enum PointerEventType {
306
410
POINTER_DOWN = 'pointerdown' ,
0 commit comments