@@ -307,7 +307,7 @@ describe('Layout images', function() {
307307
308308 afterEach ( destroyGraphDiv ) ;
309309
310- it ( 'should properly add and removing image' , function ( done ) {
310+ it ( 'should properly add and remove image' , function ( done ) {
311311 var gd = createGraphDiv ( ) ,
312312 data = [ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] } ] ,
313313 layout = { width : 500 , height : 400 } ;
@@ -425,23 +425,38 @@ describe('images log/linear axis changes', function() {
425425 // we don't try to figure out the position on a new axis / canvas
426426 // automatically when you change xref / yref, we leave it to the caller.
427427
428+ // initial clip path should end in 'xy' to match xref/yref
429+ expect ( d3 . select ( 'image' ) . attr ( 'clip-path' ) || '' ) . toMatch ( / x y \) $ / ) ;
430+
428431 // linear to log
429432 Plotly . relayout ( gd , { 'images[0].yref' : 'y2' } )
430433 . then ( function ( ) {
431434 expect ( gd . layout . images [ 0 ] . y ) . toBe ( 1 ) ;
432435
436+ expect ( d3 . select ( 'image' ) . attr ( 'clip-path' ) || '' ) . toMatch ( / x y 2 \) $ / ) ;
437+
433438 // log to paper
434439 return Plotly . relayout ( gd , { 'images[0].yref' : 'paper' } ) ;
435440 } )
436441 . then ( function ( ) {
437442 expect ( gd . layout . images [ 0 ] . y ) . toBe ( 1 ) ;
438443
444+ expect ( d3 . select ( 'image' ) . attr ( 'clip-path' ) || '' ) . toMatch ( / x \) $ / ) ;
445+
446+ // change to full paper-referenced, to make sure the clip path disappears
447+ return Plotly . relayout ( gd , { 'images[0].xref' : 'paper' } ) ;
448+ } )
449+ . then ( function ( ) {
450+ expect ( d3 . select ( 'image' ) . attr ( 'clip-path' ) ) . toBe ( null ) ;
451+
439452 // paper to log
440453 return Plotly . relayout ( gd , { 'images[0].yref' : 'y2' } ) ;
441454 } )
442455 . then ( function ( ) {
443456 expect ( gd . layout . images [ 0 ] . y ) . toBe ( 1 ) ;
444457
458+ expect ( d3 . select ( 'image' ) . attr ( 'clip-path' ) || '' ) . toMatch ( / ^ [ ^ x ] + y 2 \) $ / ) ;
459+
445460 // log to linear
446461 return Plotly . relayout ( gd , { 'images[0].yref' : 'y' } ) ;
447462 } )
0 commit comments