@@ -1348,6 +1348,10 @@ describe('annotation effects', function() {
13481348describe ( 'animating annotations' , function ( ) {
13491349 var gd ;
13501350
1351+ // Two slightly different 1x1 pngs:
1352+ var img1 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQYV2P4z/C/HgAGfgJ+p8YU1AAAAABJRU5ErkJggg==' ;
1353+ var img2 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQYV2P4//9/PQAJewN9w0ic/wAAAABJRU5ErkJggg==' ;
1354+
13511355 beforeEach ( function ( ) {
13521356 gd = createGraphDiv ( ) ;
13531357 } ) ;
@@ -1360,24 +1364,62 @@ describe('animating annotations', function() {
13601364 var texts = Plotly . d3 . select ( gd ) . selectAll ( '.annotation .annotation-text' ) ;
13611365 expect ( expected . length ) . toEqual ( texts . size ( ) ) ;
13621366
1363- texts . each ( function ( i ) {
1367+ texts . each ( function ( d , i ) {
13641368 expect ( Plotly . d3 . select ( this ) . text ( ) ) . toEqual ( expected [ i ] ) ;
13651369 } ) ;
13661370 }
13671371
1372+ function assertShapes ( expected ) {
1373+ var paths = Plotly . d3 . select ( gd ) . selectAll ( '.shapelayer path' ) ;
1374+
1375+ expect ( expected . length ) . toEqual ( paths . size ( ) ) ;
1376+
1377+ paths . each ( function ( d , i ) {
1378+ expect ( Plotly . d3 . select ( this ) . style ( 'fill' ) ) . toEqual ( expected [ i ] ) ;
1379+ } ) ;
1380+ }
1381+
1382+ function assertImages ( expected ) {
1383+ var imgs = Plotly . d3 . select ( gd ) . selectAll ( '.imagelayer image' ) ;
1384+
1385+ expect ( expected . length ) . toEqual ( imgs . size ( ) ) ;
1386+
1387+ imgs . each ( function ( d , i ) {
1388+ expect ( Plotly . d3 . select ( this ) . attr ( 'href' ) ) . toEqual ( expected [ i ] ) ;
1389+ } ) ;
1390+ }
1391+
13681392 Plotly . plot ( gd ,
13691393 [ { y : [ 1 , 2 , 3 ] } ] ,
1370- { annotations : [ { text : 'hello' } ] }
1394+ {
1395+ annotations : [ { text : 'hello' } ] ,
1396+ shapes : [ { fillcolor : 'rgb(170, 170, 170)' } ] ,
1397+ images : [ { source : img1 } ]
1398+ }
13711399 ) . then ( function ( ) {
13721400 assertAnnotations ( [ 'hello' ] ) ;
1401+ assertShapes ( [ 'rgb(170, 170, 170)' ] ) ;
1402+ assertImages ( [ img1 ] ) ;
13731403
13741404 return Plotly . animate ( gd , [ {
1375- layout : { annotations : [ { text : 'hi' } ] }
1405+ layout : {
1406+ annotations : [ { text : 'hi' } ] ,
1407+ shapes : [
1408+ { fillcolor : 'rgb(171, 171, 171)' } ,
1409+ { fillcolor : 'rgb(172, 172, 172)' }
1410+ ] ,
1411+ images : [ { source : img2 } ]
1412+ }
13761413 } ] , {
13771414 frame : { redraw : false , duration : 0 }
13781415 } ) ;
13791416 } ) . then ( function ( ) {
13801417 assertAnnotations ( [ 'hi' ] ) ;
1418+ assertShapes ( [
1419+ 'rgb(171, 171, 171)' ,
1420+ 'rgb(172, 172, 172)'
1421+ ] ) ;
1422+ assertImages ( [ img2 ] ) ;
13811423
13821424 } ) . catch ( failTest ) . then ( done ) ;
13831425 } ) ;
0 commit comments