@@ -187,23 +187,39 @@ describe('pie hovering', function() {
187187
188188 function _hover ( ) {
189189 mouseEvent ( 'mouseover' , 223 , 143 ) ;
190+ delete gd . _lastHoverTime ;
190191 }
191192
192- function assertLabel ( expected ) {
193- var labels = d3 . selectAll ( '.hovertext .nums .line' ) ;
193+ function assertLabel ( content , style ) {
194+ var g = d3 . selectAll ( '.hovertext' ) ;
195+ var lines = g . selectAll ( '.nums .line' ) ;
194196
195- expect ( labels . size ( ) ) . toBe ( expected . length ) ;
197+ expect ( lines . size ( ) ) . toBe ( content . length ) ;
196198
197- labels . each ( function ( _ , i ) {
198- expect ( d3 . select ( this ) . text ( ) ) . toBe ( expected [ i ] ) ;
199+ lines . each ( function ( _ , i ) {
200+ expect ( d3 . select ( this ) . text ( ) ) . toBe ( content [ i ] ) ;
199201 } ) ;
202+
203+ if ( style ) {
204+ var path = g . select ( 'path' ) ;
205+ expect ( path . style ( 'fill' ) ) . toEqual ( style [ 0 ] , 'bgcolor' ) ;
206+ expect ( path . style ( 'stroke' ) ) . toEqual ( style [ 1 ] , 'bordercolor' ) ;
207+
208+ var text = g . select ( 'text' ) ;
209+ expect ( parseInt ( text . style ( 'font-size' ) ) ) . toEqual ( style [ 2 ] , 'font.size' ) ;
210+ expect ( text . style ( 'font-family' ) . split ( ',' ) [ 0 ] ) . toEqual ( style [ 3 ] , 'font.family' ) ;
211+ expect ( text . style ( 'fill' ) ) . toEqual ( style [ 4 ] , 'font.color' ) ;
212+ }
200213 }
201214
202215 it ( 'should show the default selected values' , function ( done ) {
203216 Plotly . plot ( gd , mockCopy . data , mockCopy . layout )
204217 . then ( _hover )
205218 . then ( function ( ) {
206- assertLabel ( [ '4' , '5' , '33.3%' ] ) ;
219+ assertLabel (
220+ [ '4' , '5' , '33.3%' ] ,
221+ [ 'rgb(31, 119, 180)' , 'rgb(255, 255, 255)' , 13 , 'Arial' , 'rgb(255, 255, 255)' ]
222+ ) ;
207223
208224 return Plotly . restyle ( gd , 'text' , [ [ 'A' , 'B' , 'C' , 'D' , 'E' ] ] ) ;
209225 } )
@@ -224,7 +240,23 @@ describe('pie hovering', function() {
224240 . then ( _hover )
225241 . then ( function ( ) {
226242 assertLabel ( [ '4' , 'SUP' , '5' , '33.3%' ] ) ;
243+
244+ return Plotly . restyle ( gd , {
245+ 'hoverlabel.bgcolor' : [ [ 'red' , 'green' , 'blue' ] ] ,
246+ 'hoverlabel.bordercolor' : 'yellow' ,
247+ 'hoverlabel.font.size' : [ [ 15 , 20 , 30 ] ] ,
248+ 'hoverlabel.font.family' : 'Roboto' ,
249+ 'hoverlabel.font.color' : 'blue'
250+ } ) ;
251+ } )
252+ . then ( _hover )
253+ . then ( function ( ) {
254+ assertLabel (
255+ [ '4' , 'SUP' , '5' , '33.3%' ] ,
256+ [ 'rgb(255, 0, 0)' , 'rgb(255, 255, 0)' , 15 , 'Roboto' , 'rgb(0, 0, 255)' ]
257+ ) ;
227258 } )
259+ . catch ( fail )
228260 . then ( done ) ;
229261 } ) ;
230262
0 commit comments