@@ -8,6 +8,7 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
8
8
var failTest = require ( '../assets/fail_test' ) ;
9
9
var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
10
10
var assertPlotSize = require ( '../assets/custom_assertions' ) . assertPlotSize ;
11
+ var drag = require ( '../assets/drag' ) ;
11
12
12
13
13
14
describe ( 'Test colorbar:' , function ( ) {
@@ -354,5 +355,49 @@ describe('Test colorbar:', function() {
354
355
. catch ( failTest )
355
356
. then ( done ) ;
356
357
} ) ;
358
+
359
+ function getCBNode ( ) {
360
+ return document . querySelector ( '.colorbar' ) ;
361
+ }
362
+
363
+ it ( 'can drag root-level colorbars in editable mode' , function ( done ) {
364
+ Plotly . newPlot ( gd ,
365
+ [ { z : [ [ 1 , 2 ] , [ 3 , 4 ] ] , type : 'heatmap' } ] ,
366
+ { width : 400 , height : 400 } ,
367
+ { editable : true }
368
+ )
369
+ . then ( function ( ) {
370
+ expect ( gd . data [ 0 ] . colorbar ) . toBeUndefined ( ) ;
371
+ expect ( gd . _fullData [ 0 ] . colorbar . x ) . toBe ( 1.02 ) ;
372
+ expect ( gd . _fullData [ 0 ] . colorbar . y ) . toBe ( 0.5 ) ;
373
+ return drag ( getCBNode ( ) , - 100 , 100 ) ;
374
+ } )
375
+ . then ( function ( ) {
376
+ expect ( gd . data [ 0 ] . colorbar . x ) . toBeWithin ( 0.591 , 0.01 ) ;
377
+ expect ( gd . data [ 0 ] . colorbar . y ) . toBeWithin ( 0.045 , 0.01 ) ;
378
+ } )
379
+ . catch ( failTest )
380
+ . then ( done ) ;
381
+ } ) ;
382
+
383
+ it ( 'can drag marker-level colorbars in editable mode' , function ( done ) {
384
+ Plotly . newPlot ( gd ,
385
+ [ { y : [ 1 , 2 , 1 ] , marker : { color : [ 0 , 1 , 2 ] , showscale : true } } ] ,
386
+ { width : 400 , height : 400 } ,
387
+ { editable : true }
388
+ )
389
+ . then ( function ( ) {
390
+ expect ( gd . data [ 0 ] . marker . colorbar ) . toBeUndefined ( ) ;
391
+ expect ( gd . _fullData [ 0 ] . marker . colorbar . x ) . toBe ( 1.02 ) ;
392
+ expect ( gd . _fullData [ 0 ] . marker . colorbar . y ) . toBe ( 0.5 ) ;
393
+ return drag ( getCBNode ( ) , - 100 , 100 ) ;
394
+ } )
395
+ . then ( function ( ) {
396
+ expect ( gd . data [ 0 ] . marker . colorbar . x ) . toBeWithin ( 0.591 , 0.01 ) ;
397
+ expect ( gd . data [ 0 ] . marker . colorbar . y ) . toBeWithin ( 0.045 , 0.01 ) ;
398
+ } )
399
+ . catch ( failTest )
400
+ . then ( done ) ;
401
+ } ) ;
357
402
} ) ;
358
403
} ) ;
0 commit comments