@@ -207,6 +207,7 @@ describe('general transforms:', function() {
207207
208208describe ( 'user-defined transforms:' , function ( ) {
209209 'use strict' ;
210+ afterEach ( destroyGraphDiv ) ;
210211
211212 it ( 'should pass correctly arguments to transform methods' , function ( ) {
212213 var transformIn = { type : 'fake' } ;
@@ -283,7 +284,7 @@ describe('user-defined transforms:', function() {
283284 expect ( calledSupplyLayoutDefaults ) . toBe ( 1 ) ;
284285 } ) ;
285286
286- it ( 'handles `makesData` transforms when the incoming trace has no data' , function ( ) {
287+ it ( 'handles `makesData` transforms when the incoming trace has no data' , function ( done ) {
287288 var transformIn = { type : 'linemaker' , x0 : 3 , y0 : 2 , x1 : 5 , y1 : 10 , n : 3 } ;
288289 var dataIn = [ { transforms : [ transformIn ] , mode : 'lines+markers' } ] ;
289290 var fullData = [ ] ;
@@ -317,15 +318,14 @@ describe('user-defined transforms:', function() {
317318 expect ( trace . marker ) . toBeUndefined ( ) ;
318319
319320 // just put the input trace back in here, it'll get coerced again after the transform
320- var traceOut = Lib . extendFlat ( trace . _input , { x : x , y : y } ) ;
321+ var traceOut = Lib . extendFlat ( { } , trace . _input , { x : x , y : y } ) ;
321322
322323 return [ traceOut ] ;
323324 }
324325 } ;
325326
326327 Plotly . register ( lineMakerModule ) ;
327328 Plots . supplyDataDefaults ( dataIn , fullData , layout , fullLayout ) ;
328- delete Plots . transformsRegistry . linemaker ;
329329
330330 expect ( fullData . length ) . toBe ( 1 ) ;
331331 var traceOut = fullData [ 0 ] ;
@@ -336,6 +336,34 @@ describe('user-defined transforms:', function() {
336336 expect ( traceOut . mode ) . toBe ( 'lines+markers' ) ;
337337 expect ( traceOut . line ) . toBeDefined ( ) ;
338338 expect ( traceOut . marker ) . toBeDefined ( ) ;
339+
340+ // make sure plot is really drawn, and changes in the base trace
341+ // are propagated correctly on an edit (either restyle or react)
342+ var gd = createGraphDiv ( ) ;
343+ function getLineWidth ( ) {
344+ var line = gd . querySelector ( '.js-line' ) ;
345+ return line && parseFloat ( line . style . strokeWidth ) ;
346+ }
347+ Plotly . newPlot ( gd , [ { transforms : [ transformIn ] , mode : 'lines+markers' } ] , layout )
348+ . then ( function ( ) {
349+ expect ( getLineWidth ( ) ) . toBe ( 2 ) ;
350+
351+ return Plotly . restyle ( gd , 'line.width' , 7 ) ;
352+ } )
353+ . then ( function ( ) {
354+ expect ( getLineWidth ( ) ) . toBe ( 7 ) ;
355+
356+ var data2 = [ { transforms : [ transformIn ] , mode : 'lines+markers' , line : { width : 4 } } ] ;
357+ return Plotly . react ( gd , data2 , layout ) ;
358+ } )
359+ . then ( function ( ) {
360+ expect ( getLineWidth ( ) ) . toBe ( 4 ) ;
361+ } )
362+ . catch ( failTest )
363+ . then ( function ( ) {
364+ delete Plots . transformsRegistry . linemaker ;
365+ } )
366+ . then ( done ) ;
339367 } ) ;
340368
341369} ) ;
0 commit comments