@@ -728,6 +728,56 @@ describe('MDC-based MatSlider' , () => {
728
728
} ) ;
729
729
} ) ;
730
730
} ) ;
731
+
732
+ describe ( 'slider with value property binding' , ( ) => {
733
+ let fixture : ComponentFixture < SliderWithOneWayBinding > ;
734
+ let testComponent : SliderWithOneWayBinding ;
735
+ let inputInstance : MatSliderThumb ;
736
+
737
+ beforeEach ( waitForAsync ( ( ) => {
738
+ fixture = createComponent ( SliderWithOneWayBinding ) ;
739
+ fixture . detectChanges ( ) ;
740
+ testComponent = fixture . debugElement . componentInstance ;
741
+ const sliderDebugElement = fixture . debugElement . query ( By . directive ( MatSlider ) ) ;
742
+ const sliderInstance = sliderDebugElement . componentInstance ;
743
+ inputInstance = sliderInstance . _getInput ( Thumb . END ) ;
744
+ } ) ) ;
745
+
746
+ it ( 'should update when bound value changes' , ( ) => {
747
+ testComponent . value = 75 ;
748
+ fixture . detectChanges ( ) ;
749
+ expect ( inputInstance . value ) . toBe ( 75 ) ;
750
+ } ) ;
751
+ } ) ;
752
+
753
+ describe ( 'range slider with value property binding' , ( ) => {
754
+ let fixture : ComponentFixture < RangeSliderWithOneWayBinding > ;
755
+ let testComponent : RangeSliderWithOneWayBinding ;
756
+ let startInputInstance : MatSliderThumb ;
757
+ let endInputInstance : MatSliderThumb ;
758
+
759
+ beforeEach ( waitForAsync ( ( ) => {
760
+ fixture = createComponent ( RangeSliderWithOneWayBinding ) ;
761
+ fixture . detectChanges ( ) ;
762
+ testComponent = fixture . debugElement . componentInstance ;
763
+ const sliderDebugElement = fixture . debugElement . query ( By . directive ( MatSlider ) ) ;
764
+ const sliderInstance = sliderDebugElement . componentInstance ;
765
+ startInputInstance = sliderInstance . _getInput ( Thumb . START ) ;
766
+ endInputInstance = sliderInstance . _getInput ( Thumb . END ) ;
767
+ } ) ) ;
768
+
769
+ it ( 'should update when bound start value changes' , ( ) => {
770
+ testComponent . startValue = 30 ;
771
+ fixture . detectChanges ( ) ;
772
+ expect ( startInputInstance . value ) . toBe ( 30 ) ;
773
+ } ) ;
774
+
775
+ it ( 'should update when bound end value changes' , ( ) => {
776
+ testComponent . endValue = 70 ;
777
+ fixture . detectChanges ( ) ;
778
+ expect ( endInputInstance . value ) . toBe ( 70 ) ;
779
+ } ) ;
780
+ } ) ;
731
781
} ) ;
732
782
733
783
@@ -855,6 +905,30 @@ class DiscreteRangeSliderWithDisplayWith {
855
905
}
856
906
}
857
907
908
+ @Component ( {
909
+ template : `
910
+ <mat-slider>
911
+ <input [value]="value" matSliderThumb>
912
+ </mat-slider>
913
+ ` ,
914
+ } )
915
+ class SliderWithOneWayBinding {
916
+ value = 50 ;
917
+ }
918
+
919
+ @Component ( {
920
+ template : `
921
+ <mat-slider>
922
+ <input [value]="startValue" matSliderStartThumb>
923
+ <input [value]="endValue" matSliderEndThumb>
924
+ </mat-slider>
925
+ ` ,
926
+ } )
927
+ class RangeSliderWithOneWayBinding {
928
+ startValue = 25 ;
929
+ endValue = 75 ;
930
+ }
931
+
858
932
/** The pointer event types used by the MDC Slider. */
859
933
const enum PointerEventType {
860
934
POINTER_DOWN = 'pointerdown' ,
0 commit comments