@@ -111,4 +111,57 @@ describe('pie hovering', function() {
111111 } , 100 ) ;
112112 } ) ;
113113 } ) ;
114+
115+ describe ( 'labels' , function ( ) {
116+
117+ var gd ,
118+ mockCopy ;
119+
120+ beforeEach ( function ( ) {
121+ gd = createGraphDiv ( ) ;
122+ mockCopy = Lib . extendDeep ( { } , mock ) ;
123+ } ) ;
124+
125+ afterEach ( destroyGraphDiv ) ;
126+
127+ it ( 'should show the default selected values' , function ( done ) {
128+
129+ var expected = [ '4' , '5' , '33.3%' ] ;
130+
131+ Plotly . plot ( gd , mockCopy . data , mockCopy . layout ) . then ( function ( ) {
132+
133+ mouseEvent ( 'mouseover' , 230 , 150 ) ;
134+
135+ var labels = Plotly . d3 . selectAll ( '.hovertext .nums .line' ) ;
136+
137+ expect ( labels [ 0 ] . length ) . toBe ( 3 ) ;
138+
139+ labels . each ( function ( _ , i ) {
140+ expect ( Plotly . d3 . select ( this ) . text ( ) ) . toBe ( expected [ i ] ) ;
141+ } ) ;
142+ } ) . then ( done ) ;
143+ } ) ;
144+
145+ it ( 'should show the correct separators for values' , function ( done ) {
146+
147+ var expected = [ '0' , '12|345|678@91' , '99@9%' ] ;
148+
149+ mockCopy . layout . separators = '@|' ;
150+ mockCopy . data [ 0 ] . values [ 0 ] = 12345678.912 ;
151+ mockCopy . data [ 0 ] . values [ 1 ] = 10000 ;
152+
153+ Plotly . plot ( gd , mockCopy . data , mockCopy . layout ) . then ( function ( ) {
154+
155+ mouseEvent ( 'mouseover' , 230 , 150 ) ;
156+
157+ var labels = Plotly . d3 . selectAll ( '.hovertext .nums .line' ) ;
158+
159+ expect ( labels [ 0 ] . length ) . toBe ( 3 ) ;
160+
161+ labels . each ( function ( _ , i ) {
162+ expect ( Plotly . d3 . select ( this ) . text ( ) ) . toBe ( expected [ i ] ) ;
163+ } ) ;
164+ } ) . then ( done ) ;
165+ } ) ;
166+ } ) ;
114167} ) ;
0 commit comments