@@ -319,9 +319,8 @@ describe('Layout images', function() {
319
319
var gd ;
320
320
var data = [ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] } ] ;
321
321
322
- beforeEach ( function ( done ) {
323
- gd = createGraphDiv ( ) ;
324
- Plotly . newPlot ( gd , data , {
322
+ var layoutFn = function ( ) {
323
+ return {
325
324
images : [ {
326
325
source : jsLogo ,
327
326
x : 2 ,
@@ -331,12 +330,17 @@ describe('Layout images', function() {
331
330
} ] ,
332
331
width : 500 ,
333
332
height : 400
334
- } ) . then ( done ) ;
333
+ } ;
334
+ }
335
+
336
+ beforeEach ( function ( done ) {
337
+ gd = createGraphDiv ( ) ;
338
+ Plotly . newPlot ( gd , data , layoutFn ( ) ) . then ( done ) ;
335
339
} ) ;
336
340
337
341
afterEach ( destroyGraphDiv ) ;
338
342
339
- it ( 'should only create canvas if url image' , function ( done ) {
343
+ it ( 'should only create canvas if url image and staticPlot ' , function ( done ) {
340
344
var originalCreateElement = document . createElement ;
341
345
var newCanvasElement ;
342
346
spyOn ( document , 'createElement' ) . and . callFake ( function ( elementType ) {
@@ -350,7 +354,21 @@ describe('Layout images', function() {
350
354
351
355
Plotly . relayout ( gd , 'images[0].source' , dataUriImage )
352
356
. then ( function ( ) {
353
- expect ( newCanvasElement ) . toBeUndefined ( ) ;
357
+ expect ( newCanvasElement ) . withContext ( 'non-static data uri' ) . toBeUndefined ( ) ;
358
+
359
+ return Plotly . relayout ( gd , 'images[0].source' , jsLogo ) ;
360
+ } )
361
+ . then ( function ( ) {
362
+ expect ( newCanvasElement ) . withContext ( 'non-static url' ) . toBeUndefined ( ) ;
363
+
364
+ return Plotly . newPlot ( gd , data , layoutFn ( ) , { staticPlot : true } ) ;
365
+ } )
366
+ . then ( function ( ) {
367
+ newCanvasElement = undefined ;
368
+ return Plotly . relayout ( gd , 'images[0].source' , dataUriImage ) ;
369
+ } )
370
+ . then ( function ( ) {
371
+ expect ( newCanvasElement ) . withContext ( 'static data uri' ) . toBeUndefined ( ) ;
354
372
355
373
return Plotly . relayout ( gd , 'images[0].source' , jsLogo ) ;
356
374
} )
@@ -392,11 +410,21 @@ describe('Layout images', function() {
392
410
. then ( done , done . fail ) ;
393
411
} ) ;
394
412
395
- it ( 'should remove the image tag if an invalid source' , function ( done ) {
413
+ it ( 'should remove the image tag if an invalid source and staticPlot ' , function ( done ) {
396
414
var selection = d3Select ( 'image' ) ;
397
415
expect ( selection . size ( ) ) . toBe ( 1 ) ;
398
416
399
417
Plotly . relayout ( gd , 'images[0].source' , 'invalidUrl' )
418
+ . then ( function ( ) {
419
+ var newSelection = d3Select ( 'image' ) ;
420
+ expect ( newSelection . size ( ) ) . toBe ( 1 ) ;
421
+ } )
422
+ . then ( function ( ) {
423
+ return Plotly . newPlot ( gd , data , layoutFn ( ) , { staticPlot : true } ) ;
424
+ } )
425
+ . then ( function ( ) {
426
+ return Plotly . relayout ( gd , 'images[0].source' , 'invalidUrl' ) ;
427
+ } )
400
428
. then ( function ( ) {
401
429
var newSelection = d3Select ( 'image' ) ;
402
430
expect ( newSelection . size ( ) ) . toBe ( 0 ) ;
0 commit comments