@@ -10,6 +10,8 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
10
10
var mouseEvent = require ( '../assets/mouse_event' ) ;
11
11
var customMatchers = require ( '../assets/custom_matchers' ) ;
12
12
13
+ var TOL = 6 ;
14
+
13
15
14
16
describe ( 'the range slider' , function ( ) {
15
17
@@ -26,8 +28,9 @@ describe('the range slider', function() {
26
28
27
29
function testTranslate1D ( node , val ) {
28
30
var transformParts = node . getAttribute ( 'transform' ) . split ( '(' ) ;
31
+
29
32
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 ) ;
31
34
}
32
35
33
36
describe ( 'when specified as visible' , function ( ) {
@@ -174,8 +177,8 @@ describe('the range slider', function() {
174
177
handleMin = children [ 5 ] ,
175
178
handleMax = children [ 6 ] ;
176
179
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 ) ;
179
182
testTranslate1D ( handleMin , 123.32 ) ;
180
183
testTranslate1D ( handleMax , 252.65 ) ;
181
184
} )
@@ -189,8 +192,8 @@ describe('the range slider', function() {
189
192
handleMin = children [ 5 ] ,
190
193
handleMax = children [ 6 ] ;
191
194
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 ) ;
194
197
testTranslate1D ( handleMin , 123.32 ) ;
195
198
testTranslate1D ( handleMax , 619 ) ;
196
199
} )
@@ -246,26 +249,26 @@ describe('the range slider', function() {
246
249
maskMax = children [ 3 ] ;
247
250
248
251
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 ) ;
251
254
252
255
return Plotly . relayout ( gd , 'xaxis.domain' , [ 0.3 , 0.7 ] ) ;
253
256
} )
254
257
. then ( function ( ) {
255
258
var maskMin = children [ 2 ] ,
256
259
maskMax = children [ 3 ] ;
257
260
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 ) ;
260
263
261
264
return Plotly . relayout ( gd , 'width' , 400 ) ;
262
265
} )
263
266
. then ( function ( ) {
264
267
var maskMin = children [ 2 ] ,
265
268
maskMax = children [ 3 ] ;
266
269
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 ) ;
269
272
270
273
} )
271
274
. then ( done ) ;
0 commit comments