@@ -10,6 +10,8 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
1010var mouseEvent = require ( '../assets/mouse_event' ) ;
1111var customMatchers = require ( '../assets/custom_matchers' ) ;
1212
13+ var TOL = 6 ;
14+
1315
1416describe ( 'the range slider' , function ( ) {
1517
@@ -26,8 +28,9 @@ describe('the range slider', function() {
2628
2729 function testTranslate1D ( node , val ) {
2830 var transformParts = node . getAttribute ( 'transform' ) . split ( '(' ) ;
31+
2932 expect ( transformParts [ 0 ] ) . toEqual ( 'translate' ) ;
30- expect ( + transformParts [ 1 ] . split ( ',0)' ) [ 0 ] ) . toBeCloseTo ( val , - 1 ) ;
33+ expect ( + transformParts [ 1 ] . split ( ',0)' ) [ 0 ] ) . toBeWithin ( val , TOL ) ;
3134 }
3235
3336 describe ( 'when specified as visible' , function ( ) {
@@ -174,8 +177,8 @@ describe('the range slider', function() {
174177 handleMin = children [ 5 ] ,
175178 handleMax = children [ 6 ] ;
176179
177- expect ( + maskMin . getAttribute ( 'width' ) ) . toBeCloseTo ( 126.32 , - 0.5 ) ;
178- expect ( + maskMax . getAttribute ( 'width' ) ) . toBeCloseTo ( 366.34 , - 0.5 ) ;
180+ expect ( + maskMin . getAttribute ( 'width' ) ) . toBeWithin ( 125 , TOL ) ;
181+ expect ( + maskMax . getAttribute ( 'width' ) ) . toBeWithin ( 365 , TOL ) ;
179182 testTranslate1D ( handleMin , 123.32 ) ;
180183 testTranslate1D ( handleMax , 252.65 ) ;
181184 } )
@@ -189,8 +192,8 @@ describe('the range slider', function() {
189192 handleMin = children [ 5 ] ,
190193 handleMax = children [ 6 ] ;
191194
192- expect ( + maskMin . getAttribute ( 'width' ) ) . toBeCloseTo ( 126.32 , 0 ) ;
193- expect ( + maskMax . getAttribute ( 'width' ) ) . toBeCloseTo ( 0 ) ;
195+ expect ( + maskMin . getAttribute ( 'width' ) ) . toBeWithin ( 126 , TOL ) ;
196+ expect ( + maskMax . getAttribute ( 'width' ) ) . toEqual ( 0 ) ;
194197 testTranslate1D ( handleMin , 123.32 ) ;
195198 testTranslate1D ( handleMax , 619 ) ;
196199 } )
@@ -246,26 +249,26 @@ describe('the range slider', function() {
246249 maskMax = children [ 3 ] ;
247250
248251 Plotly . relayout ( gd , 'xaxis.range' , [ 5 , 10 ] ) . then ( function ( ) {
249- expect ( + maskMin . getAttribute ( 'width' ) ) . toBeCloseTo ( 63.16 , 0 ) ;
250- expect ( + maskMax . getAttribute ( 'width' ) ) . toBeCloseTo ( 492.67 , - 1 ) ;
252+ expect ( + maskMin . getAttribute ( 'width' ) ) . toBeWithin ( 63.16 , TOL ) ;
253+ expect ( + maskMax . getAttribute ( 'width' ) ) . toBeWithin ( 492.67 , TOL ) ;
251254
252255 return Plotly . relayout ( gd , 'xaxis.domain' , [ 0.3 , 0.7 ] ) ;
253256 } )
254257 . then ( function ( ) {
255258 var maskMin = children [ 2 ] ,
256259 maskMax = children [ 3 ] ;
257260
258- expect ( + maskMin . getAttribute ( 'width' ) ) . toBeCloseTo ( 25.26 , 0 ) ;
259- expect ( + maskMax . getAttribute ( 'width' ) ) . toBeCloseTo ( 197.06 , - 1 ) ;
261+ expect ( + maskMin . getAttribute ( 'width' ) ) . toBeWithin ( 25.26 , TOL ) ;
262+ expect ( + maskMax . getAttribute ( 'width' ) ) . toBeWithin ( 197.06 , TOL ) ;
260263
261264 return Plotly . relayout ( gd , 'width' , 400 ) ;
262265 } )
263266 . then ( function ( ) {
264267 var maskMin = children [ 2 ] ,
265268 maskMax = children [ 3 ] ;
266269
267- expect ( + maskMin . getAttribute ( 'width' ) ) . toBeCloseTo ( 9.22 , 0 ) ;
268- expect ( + maskMax . getAttribute ( 'width' ) ) . toBeCloseTo ( 71.95 , 0 ) ;
270+ expect ( + maskMin . getAttribute ( 'width' ) ) . toBeWithin ( 9.22 , TOL ) ;
271+ expect ( + maskMax . getAttribute ( 'width' ) ) . toBeWithin ( 71.95 , TOL ) ;
269272
270273 } )
271274 . then ( done ) ;
0 commit comments