@@ -207,6 +207,7 @@ describe('general transforms:', function() {
207
207
208
208
describe ( 'user-defined transforms:' , function ( ) {
209
209
'use strict' ;
210
+ afterEach ( destroyGraphDiv ) ;
210
211
211
212
it ( 'should pass correctly arguments to transform methods' , function ( ) {
212
213
var transformIn = { type : 'fake' } ;
@@ -283,7 +284,7 @@ describe('user-defined transforms:', function() {
283
284
expect ( calledSupplyLayoutDefaults ) . toBe ( 1 ) ;
284
285
} ) ;
285
286
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 ) {
287
288
var transformIn = { type : 'linemaker' , x0 : 3 , y0 : 2 , x1 : 5 , y1 : 10 , n : 3 } ;
288
289
var dataIn = [ { transforms : [ transformIn ] , mode : 'lines+markers' } ] ;
289
290
var fullData = [ ] ;
@@ -317,15 +318,14 @@ describe('user-defined transforms:', function() {
317
318
expect ( trace . marker ) . toBeUndefined ( ) ;
318
319
319
320
// 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 } ) ;
321
322
322
323
return [ traceOut ] ;
323
324
}
324
325
} ;
325
326
326
327
Plotly . register ( lineMakerModule ) ;
327
328
Plots . supplyDataDefaults ( dataIn , fullData , layout , fullLayout ) ;
328
- delete Plots . transformsRegistry . linemaker ;
329
329
330
330
expect ( fullData . length ) . toBe ( 1 ) ;
331
331
var traceOut = fullData [ 0 ] ;
@@ -336,6 +336,34 @@ describe('user-defined transforms:', function() {
336
336
expect ( traceOut . mode ) . toBe ( 'lines+markers' ) ;
337
337
expect ( traceOut . line ) . toBeDefined ( ) ;
338
338
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 ) ;
339
367
} ) ;
340
368
341
369
} ) ;
0 commit comments