@@ -5,7 +5,7 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
5
5
var mock = require ( '../../image/mocks/range_slider.json' ) ;
6
6
var mouseEvent = require ( '../assets/mouse_event' ) ;
7
7
8
- describe ( 'the range slider' , function ( ) {
8
+ fdescribe ( 'the range slider' , function ( ) {
9
9
10
10
var gd ,
11
11
rangeSlider ,
@@ -48,89 +48,91 @@ describe('the range slider', function() {
48
48
expect ( bg . getAttribute ( 'stroke-width' ) ) . toBe ( '2' ) ;
49
49
} ) ;
50
50
51
- it ( 'should react to resizing the minimum handle' , function ( ) {
51
+ it ( 'should react to resizing the minimum handle' , function ( done ) {
52
52
var start = 85 ,
53
53
end = 140 ,
54
54
dataMinStart = rangeSlider . getAttribute ( 'data-min' ) ,
55
55
diff = end - start ;
56
56
57
- slide ( start , 400 , end , 400 ) ;
57
+ slide ( start , 400 , end , 400 ) . then ( function ( ) {
58
+ var maskMin = children [ 2 ] ,
59
+ handleMin = children [ 5 ] ;
58
60
59
- var maskMin = children [ 2 ] ,
60
- handleMin = children [ 5 ] ;
61
-
62
- expect ( rangeSlider . getAttribute ( 'data-min' ) ) . toEqual ( String ( + dataMinStart + diff ) ) ;
63
- expect ( maskMin . getAttribute ( 'width' ) ) . toEqual ( String ( diff ) ) ;
64
- expect ( handleMin . getAttribute ( 'transform' ) ) . toBe ( 'translate(' + ( diff - 3 ) + ')' ) ;
61
+ expect ( rangeSlider . getAttribute ( 'data-min' ) ) . toEqual ( String ( + dataMinStart + diff ) ) ;
62
+ expect ( maskMin . getAttribute ( 'width' ) ) . toEqual ( String ( diff ) ) ;
63
+ expect ( handleMin . getAttribute ( 'transform' ) ) . toBe ( 'translate(' + ( diff - 3 ) + ')' ) ;
64
+ } ) . then ( done ) ;
65
65
} ) ;
66
66
67
- it ( 'should react to resizing the maximum handle' , function ( ) {
67
+ it ( 'should react to resizing the maximum handle' , function ( done ) {
68
68
var start = 705 ,
69
69
end = 500 ,
70
70
dataMaxStart = rangeSlider . getAttribute ( 'data-max' ) ,
71
71
diff = end - start ;
72
72
73
- slide ( start , 400 , end , 400 ) ;
74
-
75
- var maskMax = children [ 3 ] ,
76
- handleMax = children [ 6 ] ;
73
+ slide ( start , 400 , end , 400 ) . then ( function ( ) {
74
+ var maskMax = children [ 3 ] ,
75
+ handleMax = children [ 6 ] ;
77
76
78
- expect ( rangeSlider . getAttribute ( 'data-max' ) ) . toEqual ( String ( + dataMaxStart + diff ) ) ;
79
- expect ( maskMax . getAttribute ( 'width' ) ) . toEqual ( String ( - diff ) ) ;
80
- expect ( handleMax . getAttribute ( 'transform' ) ) . toBe ( 'translate(' + ( + dataMaxStart + diff ) + ')' ) ;
77
+ expect ( rangeSlider . getAttribute ( 'data-max' ) ) . toEqual ( String ( + dataMaxStart + diff ) ) ;
78
+ expect ( maskMax . getAttribute ( 'width' ) ) . toEqual ( String ( - diff ) ) ;
79
+ expect ( handleMax . getAttribute ( 'transform' ) ) . toBe ( 'translate(' + ( + dataMaxStart + diff ) + ')' ) ;
80
+ } ) . then ( done ) ;
81
81
} ) ;
82
82
83
- it ( 'should react to moving the slidebox left to right' , function ( ) {
83
+ it ( 'should react to moving the slidebox left to right' , function ( done ) {
84
84
var start = 250 ,
85
85
end = 300 ,
86
86
dataMinStart = rangeSlider . getAttribute ( 'data-min' ) ,
87
87
diff = end - start ;
88
88
89
- slide ( start , 400 , end , 400 ) ;
90
-
91
- var maskMin = children [ 2 ] ,
92
- handleMin = children [ 5 ] ;
89
+ slide ( start , 400 , end , 400 ) . then ( function ( ) {
90
+ var maskMin = children [ 2 ] ,
91
+ handleMin = children [ 5 ] ;
93
92
94
- expect ( rangeSlider . getAttribute ( 'data-min' ) ) . toEqual ( String ( + dataMinStart + diff ) ) ;
95
- expect ( maskMin . getAttribute ( 'width' ) ) . toEqual ( String ( diff ) ) ;
96
- expect ( handleMin . getAttribute ( 'transform' ) ) . toEqual ( 'translate(' + ( + dataMinStart + diff - 3 ) + ')' ) ;
93
+ expect ( rangeSlider . getAttribute ( 'data-min' ) ) . toEqual ( String ( + dataMinStart + diff ) ) ;
94
+ expect ( maskMin . getAttribute ( 'width' ) ) . toEqual ( String ( diff ) ) ;
95
+ expect ( handleMin . getAttribute ( 'transform' ) ) . toEqual ( 'translate(' + ( + dataMinStart + diff - 3 ) + ')' ) ;
96
+ } ) . then ( done ) ;
97
97
} ) ;
98
98
99
- it ( 'should react to moving the slidebox right to left' , function ( ) {
99
+ it ( 'should react to moving the slidebox right to left' , function ( done ) {
100
100
var start = 300 ,
101
101
end = 250 ,
102
102
dataMaxStart = rangeSlider . getAttribute ( 'data-max' ) ,
103
103
diff = end - start ;
104
104
105
- slide ( start , 400 , end , 400 ) ;
105
+ slide ( start , 400 , end , 400 ) . then ( function ( ) {
106
+ var maskMax = children [ 3 ] ,
107
+ handleMax = children [ 6 ] ;
108
+
109
+ expect ( rangeSlider . getAttribute ( 'data-max' ) ) . toEqual ( String ( + dataMaxStart + diff ) ) ;
110
+ expect ( maskMax . getAttribute ( 'width' ) ) . toEqual ( String ( - diff ) ) ;
111
+ expect ( handleMax . getAttribute ( 'transform' ) ) . toEqual ( 'translate(' + ( + dataMaxStart + diff ) + ')' ) ;
112
+ } ) . then ( done ) ;
106
113
107
- var maskMax = children [ 3 ] ,
108
- handleMax = children [ 6 ] ;
109
114
110
- expect ( rangeSlider . getAttribute ( 'data-max' ) ) . toEqual ( String ( + dataMaxStart + diff ) ) ;
111
- expect ( maskMax . getAttribute ( 'width' ) ) . toEqual ( String ( - diff ) ) ;
112
- expect ( handleMax . getAttribute ( 'transform' ) ) . toEqual ( 'translate(' + ( + dataMaxStart + diff ) + ')' ) ;
113
115
} ) ;
114
116
115
- it ( 'should resize the main plot when rangeslider has moved' , function ( ) {
117
+ it ( 'should resize the main plot when rangeslider has moved' , function ( done ) {
116
118
var start = 300 ,
117
119
end = 400 ,
118
- rangeDiff1 = gd . _fullLayout . xaxis . range [ 1 ] - gd . _fullLayout . xaxis . range [ 0 ] ;
119
-
120
- slide ( start , 400 , end , 400 ) ;
121
-
122
- var rangeDiff2 = gd . _fullLayout . xaxis . range [ 1 ] - gd . _fullLayout . xaxis . range [ 0 ] ;
123
-
124
- expect ( rangeDiff2 ) . toBeLessThan ( rangeDiff1 ) ;
125
-
126
- start = 400 ;
127
- end = 200 ;
128
-
129
- slide ( start , 400 , end , 400 ) ;
130
-
131
- var rangeDiff3 = gd . _fullLayout . xaxis . range [ 1 ] - gd . _fullLayout . xaxis . range [ 0 ] ;
132
-
133
- expect ( rangeDiff3 ) . toBeLessThan ( rangeDiff2 ) ;
120
+ rangeDiff1 = gd . _fullLayout . xaxis . range [ 1 ] - gd . _fullLayout . xaxis . range [ 0 ] ,
121
+ rangeDiff2 ,
122
+ rangeDiff3 ;
123
+
124
+ slide ( start , 400 , end , 400 ) . then ( function ( ) {
125
+ rangeDiff2 = gd . _fullLayout . xaxis . range [ 1 ] - gd . _fullLayout . xaxis . range [ 0 ] ;
126
+ expect ( rangeDiff2 ) . toBeLessThan ( rangeDiff1 ) ;
127
+ } ) . then ( function ( ) {
128
+ start = 400 ;
129
+ end = 200 ;
130
+
131
+ return slide ( start , 400 , end , 400 ) ;
132
+ } ) . then ( function ( ) {
133
+ rangeDiff3 = gd . _fullLayout . xaxis . range [ 1 ] - gd . _fullLayout . xaxis . range [ 0 ] ;
134
+ expect ( rangeDiff3 ) . toBeLessThan ( rangeDiff2 ) ;
135
+ } ) . then ( done ) ;
134
136
} ) ;
135
137
} ) ;
136
138
@@ -310,8 +312,14 @@ describe('the range slider', function() {
310
312
311
313
312
314
function slide ( fromX , fromY , toX , toY ) {
313
- mouseEvent ( 'mousemove' , fromX , fromY ) ;
314
- mouseEvent ( 'mousedown' , fromX , fromY ) ;
315
- mouseEvent ( 'mousemove' , toX , toY ) ;
316
- mouseEvent ( 'mouseup' , toX , toY ) ;
315
+ return new Promise ( function ( resolve ) {
316
+ mouseEvent ( 'mousemove' , fromX , fromY ) ;
317
+ mouseEvent ( 'mousedown' , fromX , fromY ) ;
318
+ mouseEvent ( 'mousemove' , toX , toY ) ;
319
+ mouseEvent ( 'mouseup' , toX , toY ) ;
320
+
321
+ setTimeout ( function ( ) {
322
+ return resolve ( ) ;
323
+ } , 20 ) ;
324
+ } ) ;
317
325
}
0 commit comments