@@ -135,6 +135,17 @@ describe("RemoteFigure.changeAxisFeature", function() {
135
135
} ) ;
136
136
} ) ;
137
137
138
+ describe ( "RemoteFigure.setFeatureFilters" , function ( ) {
139
+ it ( 'should write values in axes[0].rubberBand' , function ( ) {
140
+ const figure = new RemoteFigure ( data , canvas . width , canvas . height , 100 , 100 , canvas . id ) ;
141
+ figure . setCanvas ( canvas . id ) ;
142
+ figure . axes [ 0 ] = new Axis ( figure . features . get ( "x" ) , new Rect ( new Vertex ( ) , new Vertex ( 100 , 100 ) ) , new Vertex ( ) , new Vertex ( 100 , 0 ) , "x" , new Vertex ( ) ) ;
143
+ figure . setFeatureFilter ( "x" , - 1 , 1.1 ) ;
144
+ expect ( figure . selectedIndices . length , "figure.selectedIndices.length" ) . to . be . equal ( 2 ) ;
145
+ } ) ;
146
+ } ) ;
147
+
148
+
138
149
describe ( "RemoteFigure.resizeUpdate" , function ( ) {
139
150
it ( "should resize figure" , function ( ) {
140
151
const figure = new RemoteFigure ( data , canvas . width , canvas . height , 100 , 100 , canvas . id ) ;
@@ -147,16 +158,6 @@ describe("RemoteFigure.resizeUpdate", function() {
147
158
} ) ;
148
159
} ) ;
149
160
150
- describe ( "RemoteFigure.resizeWindow" , function ( ) {
151
- it ( "should resize figure with new window size" , function ( ) {
152
- const figure = new RemoteFigure ( data , canvas . width , canvas . height , 100 , 100 , canvas . id ) ;
153
- figure . setCanvas ( canvas . id ) ;
154
- figure . resizeWindow ( 700 , 500 ) ;
155
- expect ( figure . size . x , "size.x" ) . to . be . equal ( 700 ) ;
156
- expect ( figure . size . y , "size.y" ) . to . be . equal ( 500 ) ;
157
- } ) ;
158
- } ) ;
159
-
160
161
describe ( "RemoteFigure.reset" , function ( ) {
161
162
it ( "should reset scales and selectors" , function ( ) {
162
163
const figure = new RemoteFigure ( data , canvas . width , canvas . height , 100 , 100 , canvas . id ) ;
@@ -214,6 +215,7 @@ describe("RemoteFigure.mouseListener", function() {
214
215
const mouseDown = new MouseEvent ( 'mousedown' , { clientX : 150 , clientY : 150 } ) ;
215
216
const mouseMove1 = new MouseEvent ( 'mousemove' , { clientX : 150 , clientY : 150 } ) ;
216
217
const mouseMove2 = new MouseEvent ( 'mousemove' , { clientX : 370 , clientY : 520 } ) ;
218
+ const mouseMove3 = new MouseEvent ( 'mousemove' , { clientX : 20000 , clientY : 0 } ) ;
217
219
const mouseWheel = new WheelEvent ( 'wheel' , { clientX : 150 , clientY : 150 , deltaY : ZOOM_FACTOR } ) ;
218
220
const mouseLeave = new MouseEvent ( 'mouseleave' , { } ) ;
219
221
@@ -262,6 +264,19 @@ describe("RemoteFigure.mouseListener", function() {
262
264
expect ( canvas . style . cursor , "default cursor" ) . to . be . equal ( "default" ) ;
263
265
} ) ;
264
266
267
+ it ( "should preserve rubberBand min and max values" , function ( ) {
268
+ figure . axes [ 0 ] . rubberBand . minValue = 0 ;
269
+ figure . axes [ 0 ] . rubberBand . maxValue = 200 ;
270
+ figure . draw ( ) ;
271
+ expect ( figure . axes [ 0 ] . rubberBand . canvasLength , "rubberBand.canvasLength" ) . to . be . closeTo ( 764 , 1. ) ;
272
+ canvas . dispatchEvent ( mouseMove1 ) ;
273
+ canvas . dispatchEvent ( mouseDown ) ;
274
+ canvas . dispatchEvent ( mouseMove3 ) ;
275
+ canvas . dispatchEvent ( mouseUp ) ;
276
+ expect ( figure . axes [ 0 ] . rubberBand . canvasLength , "rubberBand.canvasLength" ) . to . be . equal ( 0 ) ;
277
+ figure . reset ( ) ;
278
+ } ) ;
279
+
265
280
it ( "should translate figure" , function ( ) {
266
281
canvas . dispatchEvent ( mouseMove1 ) ;
267
282
canvas . dispatchEvent ( mouseDown ) ;
@@ -273,7 +288,7 @@ describe("RemoteFigure.mouseListener", function() {
273
288
274
289
expect ( figure . translation , "translation" ) . to . deep . equal ( new Vertex ( ) ) ;
275
290
} ) ;
276
-
291
+
277
292
it ( "should handle wheel events" , function ( ) {
278
293
const minValue0 = figure . axes [ 0 ] . minValue ;
279
294
const maxValue0 = figure . axes [ 0 ] . maxValue ;
@@ -295,16 +310,16 @@ describe("RemoteFigure.mouseListener", function() {
295
310
const maxValue1 = figure . axes [ 1 ] . maxValue ;
296
311
297
312
figure . zoomIn ( ) ;
298
- expect ( figure . axes [ 0 ] . minValue , "minValue0" ) . to . not . be . equal ( minValue0 ) ;
299
- expect ( figure . axes [ 0 ] . maxValue , "maxValue0" ) . to . not . be . equal ( maxValue0 ) ;
300
- expect ( figure . axes [ 1 ] . minValue , "minValue0" ) . to . not . be . equal ( minValue1 ) ;
301
- expect ( figure . axes [ 1 ] . maxValue , "maxValue1" ) . to . not . be . equal ( maxValue1 ) ;
313
+ expect ( figure . axes [ 0 ] . minValue , "minValue0" ) . to . not . be . closeTo ( minValue0 , 0.001 ) ;
314
+ expect ( figure . axes [ 0 ] . maxValue , "maxValue0" ) . to . not . be . closeTo ( maxValue0 , 0.001 ) ;
315
+ expect ( figure . axes [ 1 ] . minValue , "minValue0" ) . to . not . be . closeTo ( minValue1 , 0.001 ) ;
316
+ expect ( figure . axes [ 1 ] . maxValue , "maxValue1" ) . to . not . be . closeTo ( maxValue1 , 0.001 ) ;
302
317
303
318
figure . zoomOut ( ) ;
304
- expect ( figure . axes [ 0 ] . minValue , "minValue0" ) . to . be . equal ( minValue0 ) ;
305
- expect ( figure . axes [ 0 ] . maxValue , "maxValue0" ) . to . be . equal ( maxValue0 ) ;
306
- expect ( figure . axes [ 1 ] . minValue , "minValue0" ) . to . be . equal ( minValue1 ) ;
307
- expect ( figure . axes [ 1 ] . maxValue , "maxValue1" ) . to . be . equal ( maxValue1 ) ;
319
+ expect ( figure . axes [ 0 ] . minValue , "minValue0" ) . to . be . closeTo ( minValue0 , 0.001 ) ;
320
+ expect ( figure . axes [ 0 ] . maxValue , "maxValue0" ) . to . be . closeTo ( maxValue0 , 0.001 ) ;
321
+ expect ( figure . axes [ 1 ] . minValue , "minValue0" ) . to . be . closeTo ( minValue1 , 0.001 ) ;
322
+ expect ( figure . axes [ 1 ] . maxValue , "maxValue1" ) . to . be . closeTo ( maxValue1 , 0.001 ) ;
308
323
} ) ;
309
324
310
325
it ( "should reset state correctly on mouseleave" , function ( ) {
0 commit comments