@@ -3666,8 +3666,8 @@ describe('hovermode: (x|y)unified', function() {
36663666 Lib . clearThrottle ( ) ;
36673667 }
36683668
3669- function assertElementCount ( className , size ) {
3670- var g = d3 . selectAll ( 'g.' + className ) ;
3669+ function assertElementCount ( selector , size ) {
3670+ var g = d3 . selectAll ( selector ) ;
36713671 expect ( g . size ( ) ) . toBe ( size ) ;
36723672 }
36733673
@@ -3788,6 +3788,28 @@ describe('hovermode: (x|y)unified', function() {
37883788 . then ( done ) ;
37893789 } ) ;
37903790
3791+ it ( 'shares filtering logic with compare mode x' , function ( done ) {
3792+ var mock = require ( '@mocks/27.json' ) ;
3793+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
3794+
3795+ Plotly . newPlot ( gd , mockCopy )
3796+ . then ( function ( gd ) {
3797+ _hover ( gd , { xval : '2002' } ) ;
3798+ assertElementCount ( 'g.hovertext' , 2 ) ;
3799+
3800+ return Plotly . relayout ( gd , 'hovermode' , 'x unified' ) ;
3801+ } )
3802+ . then ( function ( ) {
3803+ _hover ( gd , { xval : '2002' } ) ;
3804+ assertLabel ( { title : '2002.042' , items : [
3805+ 'Market income : 0.5537845' ,
3806+ 'Market incom... : 0.4420997'
3807+ ] } ) ;
3808+ } )
3809+ . catch ( failTest )
3810+ . then ( done ) ;
3811+ } ) ;
3812+
37913813 it ( 'should order items in the same way as the legend' , function ( done ) {
37923814 var mock = require ( '@mocks/stacked_area.json' ) ;
37933815 var mockCopy = Lib . extendDeep ( { } , mock ) ;
@@ -3826,6 +3848,21 @@ describe('hovermode: (x|y)unified', function() {
38263848 . then ( done ) ;
38273849 } ) ;
38283850
3851+ it ( 'should work for "legend_horizontal_autowrap"' , function ( done ) {
3852+ var mock = require ( '@mocks/legend_horizontal_autowrap.json' ) ;
3853+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
3854+ mockCopy . layout . hovermode = 'x unified' ;
3855+ Plotly . newPlot ( gd , mockCopy )
3856+ . then ( function ( gd ) {
3857+ _hover ( gd , { xval : 1 } ) ;
3858+
3859+ assertElementCount ( 'g.hoverlayer g.legend' , 1 ) ;
3860+ assertElementCount ( 'g.hoverlayer g.traces' , 20 ) ;
3861+ } )
3862+ . catch ( failTest )
3863+ . then ( done ) ;
3864+ } ) ;
3865+
38293866 it ( 'should style scatter symbols accordingly' , function ( done ) {
38303867 var mock = require ( '@mocks/marker_colorscale_template.json' ) ;
38313868 var mockCopy = Lib . extendDeep ( { } , mock ) ;
@@ -3934,16 +3971,16 @@ describe('hovermode: (x|y)unified', function() {
39343971 . then ( function ( gd ) {
39353972 _hover ( gd , { xval : 3 } ) ;
39363973
3937- assertElementCount ( 'hovertext' , 2 ) ;
3938- assertElementCount ( 'legend' , 0 ) ;
3974+ assertElementCount ( 'g. hovertext' , 2 ) ;
3975+ assertElementCount ( 'g. legend' , 0 ) ;
39393976
39403977 return Plotly . relayout ( gd , 'hovermode' , 'x unified' ) ;
39413978 } )
39423979 . then ( function ( gd ) {
39433980 _hover ( gd , { xval : 3 } ) ;
39443981
3945- assertElementCount ( 'hovertext' , 0 ) ;
3946- assertElementCount ( 'legend' , 1 ) ;
3982+ assertElementCount ( 'g. hovertext' , 0 ) ;
3983+ assertElementCount ( 'g. legend' , 1 ) ;
39473984 } )
39483985 . catch ( failTest )
39493986 . then ( done ) ;
0 commit comments