@@ -1251,4 +1251,38 @@ describe('annotation effects', function() {
12511251 . catch ( failTest )
12521252 . then ( done ) ;
12531253 } ) ;
1254+
1255+ it ( 'makes the whole text box a link if the link is the whole text' , function ( done ) {
1256+ makePlot ( [
1257+ { x : 20 , y : 20 , text : '<a href="https://plot.ly">Plot</a>' , showarrow : false } ,
1258+ { x : 50 , y : 50 , text : '<a href="https://plot.ly">or</a> not' , showarrow : false } ,
1259+ { x : 80 , y : 80 , text : '<a href="https://plot.ly">arrow</a>' } ,
1260+ { x : 20 , y : 80 , text : 'nor <a href="https://plot.ly">this</a>' }
1261+ ] )
1262+ . then ( function ( ) {
1263+ function checkBoxLink ( index , isLink ) {
1264+ var boxLink = d3 . selectAll ( '.annotation[data-index="' + index + '"] g>a' ) ;
1265+ expect ( boxLink . size ( ) ) . toBe ( isLink ? 1 : 0 ) ;
1266+
1267+ var textLink = d3 . selectAll ( '.annotation[data-index="' + index + '"] text a' ) ;
1268+ expect ( textLink . size ( ) ) . toBe ( 1 ) ;
1269+ checkLink ( textLink ) ;
1270+
1271+ if ( isLink ) checkLink ( boxLink ) ;
1272+ }
1273+
1274+ function checkLink ( link ) {
1275+ expect ( link . style ( 'cursor' ) ) . toBe ( 'pointer' ) ;
1276+ expect ( link . attr ( 'xlink:href' ) ) . toBe ( 'https://plot.ly' ) ;
1277+ expect ( link . attr ( 'xlink:show' ) ) . toBe ( 'new' ) ;
1278+ }
1279+
1280+ checkBoxLink ( 0 , true ) ;
1281+ checkBoxLink ( 1 , false ) ;
1282+ checkBoxLink ( 2 , true ) ;
1283+ checkBoxLink ( 3 , false ) ;
1284+ } )
1285+ . catch ( failTest )
1286+ . then ( done ) ;
1287+ } ) ;
12541288} ) ;
0 commit comments