@@ -2,6 +2,7 @@ var Plotly = require('@lib/index');
22var Plots = require ( '@src/plots/plots' ) ;
33var Lib = require ( '@src/lib' ) ;
44
5+ var d3 = require ( 'd3' ) ;
56var createGraphDiv = require ( '../assets/create_graph_div' ) ;
67var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
78
@@ -417,9 +418,34 @@ describe('finance charts updates:', function() {
417418 it ( 'Plotly.restyle should work' , function ( done ) {
418419 var trace0 = Lib . extendDeep ( { } , mock0 , { type : 'ohlc' } ) ;
419420
420- Plotly . plot ( gd , [ trace0 ] ) . then ( function ( ) {
421+ var path0 ;
421422
422- // gotta test 'tickwidth' and 'whiskerwitdth'
423+ Plotly . plot ( gd , [ trace0 ] ) . then ( function ( ) {
424+ expect ( gd . calcdata [ 0 ] [ 0 ] . x ) . toEqual ( - 0.05 ) ;
425+ expect ( gd . calcdata [ 0 ] [ 0 ] . y ) . toEqual ( 33.01 ) ;
426+
427+ return Plotly . restyle ( gd , 'tickwidth' , 0.5 ) ;
428+ } )
429+ . then ( function ( ) {
430+ expect ( gd . calcdata [ 0 ] [ 0 ] . x ) . toEqual ( - 0.5 ) ;
431+
432+ return Plotly . restyle ( gd , 'open' , [ [ 0 , 30.75 , 32.87 , 31.62 , 30.81 , 32.75 , 32.75 , 32.87 ] ] ) ;
433+ } )
434+ . then ( function ( ) {
435+ expect ( gd . calcdata [ 0 ] [ 0 ] . y ) . toEqual ( 0 ) ;
436+
437+ return Plotly . restyle ( gd , {
438+ type : 'candlestick' ,
439+ open : [ [ 33.01 , 33.31 , 33.50 , 32.06 , 34.12 , 33.05 , 33.31 , 33.50 ] ]
440+ } ) ;
441+ } )
442+ . then ( function ( ) {
443+ path0 = d3 . select ( 'path.box' ) . attr ( 'd' ) ;
444+
445+ return Plotly . restyle ( gd , 'whiskerwidth' , 0.2 ) ;
446+ } )
447+ . then ( function ( ) {
448+ expect ( d3 . select ( 'path.box' ) . attr ( 'd' ) ) . not . toEqual ( path0 ) ;
423449
424450 done ( ) ;
425451 } ) ;
0 commit comments