@@ -896,7 +896,7 @@ describe('Test plot api', function() {
896896 } ) ;
897897 } ) ;
898898
899- describe ( 'cleanData' , function ( ) {
899+ describe ( 'cleanData & cleanLayout ' , function ( ) {
900900 var gd ;
901901
902902 beforeEach ( function ( ) {
@@ -1039,6 +1039,36 @@ describe('Test plot api', function() {
10391039 expect ( trace1 . transforms . length ) . toEqual ( 1 ) ;
10401040 expect ( trace1 . transforms [ 0 ] . target ) . toEqual ( 'y' ) ;
10411041 } ) ;
1042+
1043+ it ( 'should cleanup annotations / shapes refs' , function ( ) {
1044+ var data = [ { } ] ;
1045+
1046+ var layout = {
1047+ annotations : [
1048+ { ref : 'paper' } ,
1049+ null ,
1050+ { xref : 'x02' , yref : 'y1' }
1051+ ] ,
1052+ shapes : [
1053+ { xref : 'y' , yref : 'x' } ,
1054+ null ,
1055+ { xref : 'x03' , yref : 'y1' }
1056+ ]
1057+ } ;
1058+
1059+ Plotly . plot ( gd , data , layout ) ;
1060+
1061+ expect ( gd . layout . annotations [ 0 ] ) . toEqual ( { xref : 'paper' , yref : 'paper' } ) ;
1062+ expect ( gd . layout . annotations [ 1 ] ) . toEqual ( null ) ;
1063+ expect ( gd . layout . annotations [ 2 ] ) . toEqual ( { xref : 'x2' , yref : 'y' } ) ;
1064+
1065+ expect ( gd . layout . shapes [ 0 ] . xref ) . toBeUndefined ( ) ;
1066+ expect ( gd . layout . shapes [ 0 ] . yref ) . toBeUndefined ( ) ;
1067+ expect ( gd . layout . shapes [ 1 ] ) . toEqual ( null ) ;
1068+ expect ( gd . layout . shapes [ 2 ] . xref ) . toEqual ( 'x3' ) ;
1069+ expect ( gd . layout . shapes [ 2 ] . yref ) . toEqual ( 'y' ) ;
1070+
1071+ } ) ;
10421072 } ) ;
10431073
10441074 describe ( 'Plotly.newPlot' , function ( ) {
0 commit comments