@@ -132,6 +132,46 @@ describe('hover info', function() {
132132 } ) ;
133133 } ) ;
134134
135+ describe ( 'hover info text with 0' , function ( ) {
136+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
137+
138+ mockCopy . data [ 0 ] . text = [ ] ;
139+ // we treat number 0 as valid text
140+ // see https://github.com/plotly/plotly.js/issues/2660
141+ mockCopy . data [ 0 ] . text [ 17 ] = 0 ;
142+ mockCopy . data [ 0 ] . hoverinfo = 'text' ;
143+ mockCopy . data [ 0 ] . mode = 'lines+markers+text' ;
144+
145+ beforeEach ( function ( done ) {
146+ Plotly . plot ( createGraphDiv ( ) , mockCopy . data , mockCopy . layout ) . then ( done ) ;
147+ } ) ;
148+
149+ it ( 'responds to hover text' , function ( ) {
150+ var gd = document . getElementById ( 'graph' ) ;
151+ Fx . hover ( 'graph' , evt , 'xy' ) ;
152+
153+ var hoverTrace = gd . _hoverdata [ 0 ] ;
154+
155+ expect ( hoverTrace . curveNumber ) . toBe ( 0 ) ;
156+ expect ( hoverTrace . pointNumber ) . toBe ( 17 ) ;
157+ expect ( hoverTrace . x ) . toBe ( 0.388 ) ;
158+ expect ( hoverTrace . y ) . toBe ( 1 ) ;
159+ expect ( hoverTrace . text ) . toBe ( 0 ) ;
160+
161+ var txs = d3 . select ( gd ) . selectAll ( '.textpoint text' ) ;
162+
163+ expect ( txs . size ( ) ) . toBe ( 1 ) ;
164+
165+ txs . each ( function ( ) {
166+ expect ( d3 . select ( this ) . text ( ) ) . toBe ( '0' ) ;
167+ } ) ;
168+
169+ assertHoverLabelContent ( {
170+ nums : '0'
171+ } ) ;
172+ } ) ;
173+ } ) ;
174+
135175 describe ( 'hover info all' , function ( ) {
136176 var mockCopy = Lib . extendDeep ( { } , mock ) ;
137177
0 commit comments