@@ -119,6 +119,54 @@ describe('md-slider', function() {
119
119
expect ( $rootScope . model ) . toBe ( 100 ) ;
120
120
} ) ) ;
121
121
122
+ it ( 'should update the thumb text' , inject ( function ( $compile , $rootScope , $timeout , $mdConstant ) {
123
+ var slider = $compile ( '<md-slider ng-model="value" min="0" max="100">' ) ( $rootScope ) ;
124
+ var sliderCtrl = slider . controller ( 'mdSlider' ) ;
125
+
126
+ spyOn ( slider [ 0 ] . querySelector ( '.md-track-container' ) , 'getBoundingClientRect' ) . andReturn ( {
127
+ width : 100 ,
128
+ left : 0 ,
129
+ right : 0
130
+ } ) ;
131
+
132
+ sliderCtrl . _onInput ( simulateEventAt ( 30 , Hammer . INPUT_START ) ) ;
133
+ $timeout . flush ( ) ;
134
+ expect ( slider [ 0 ] . querySelector ( '.md-thumb-text' ) . textContent ) . toBe ( '30' ) ;
135
+
136
+ slider . triggerHandler ( {
137
+ type : 'keydown' ,
138
+ keyCode : $mdConstant . KEY_CODE . LEFT_ARROW
139
+ } ) ;
140
+ $timeout . flush ( ) ;
141
+ expect ( slider [ 0 ] . querySelector ( '.md-thumb-text' ) . textContent ) . toBe ( '29' ) ;
142
+
143
+ sliderCtrl . _onPan ( simulateEventAt ( 30 ) ) ;
144
+ $timeout . flush ( ) ;
145
+ expect ( slider [ 0 ] . querySelector ( '.md-thumb-text' ) . textContent ) . toBe ( '30' ) ;
146
+ } ) ) ;
147
+
148
+ it ( 'should update the thumb text with the model value when using ng-change' , inject ( function ( $compile , $rootScope , $timeout ) {
149
+ $scope = $rootScope . $new ( ) ;
150
+
151
+ $scope . stayAt50 = function ( ) {
152
+ $scope . value = 50 ;
153
+ } ;
154
+
155
+ var slider = $compile ( '<md-slider ng-model="value" min="0" max="100" ng-change="stayAt50()">' ) ( $scope ) ;
156
+ var sliderCtrl = slider . controller ( 'mdSlider' ) ;
157
+
158
+ spyOn ( slider [ 0 ] . querySelector ( '.md-track-container' ) , 'getBoundingClientRect' ) . andReturn ( {
159
+ width : 100 ,
160
+ left : 0 ,
161
+ right : 0
162
+ } ) ;
163
+
164
+ sliderCtrl . _onInput ( simulateEventAt ( 30 , Hammer . INPUT_START ) ) ;
165
+ $timeout . flush ( ) ;
166
+ expect ( $scope . value ) . toBe ( 50 ) ;
167
+ expect ( slider [ 0 ] . querySelector ( '.md-thumb-text' ) . textContent ) . toBe ( '50' ) ;
168
+ } ) ) ;
169
+
122
170
it ( 'should call $log.warn if aria-label isnt provided' , inject ( function ( $compile , $rootScope , $timeout , $log ) {
123
171
spyOn ( $log , "warn" ) ;
124
172
var element = $compile (
0 commit comments