@@ -5,6 +5,7 @@ var d3 = require('d3');
5
5
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
6
6
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
7
7
var fail = require ( '../assets/fail_test.js' ) ;
8
+ var assertHoverLabelStyle = require ( '../assets/custom_assertions' ) . assertHoverLabelStyle ;
8
9
9
10
// cartesian click events events use the hover data
10
11
// from the mousemove events and then simulate
@@ -130,22 +131,6 @@ describe('Test hover and click interactions', function() {
130
131
expect ( String ( pt . pointNumber ) ) . toBe ( String ( expected . pointNumber ) , msg + ' - point number' ) ;
131
132
}
132
133
133
- function assertHoverLabelStyle ( sel , expected , msg ) {
134
- if ( sel . node ( ) === null ) {
135
- expect ( expected . noHoverLabel ) . toBe ( true ) ;
136
- return ;
137
- }
138
-
139
- var path = sel . select ( 'path' ) ;
140
- expect ( path . style ( 'fill' ) ) . toBe ( expected . bgColor , msg + ' - bgcolor' ) ;
141
- expect ( path . style ( 'stroke' ) ) . toBe ( expected . borderColor , msg + ' - bordercolor' ) ;
142
-
143
- var text = sel . select ( 'text.nums' ) ;
144
- expect ( parseInt ( text . style ( 'font-size' ) ) ) . toBe ( expected . fontSize , msg + ' - font.size' ) ;
145
- expect ( text . style ( 'font-family' ) . split ( ',' ) [ 0 ] ) . toBe ( expected . fontFamily , msg + ' - font.family' ) ;
146
- expect ( text . style ( 'fill' ) ) . toBe ( expected . fontColor , msg + ' - font.color' ) ;
147
- }
148
-
149
134
function assertHoveLabelContent ( expected ) {
150
135
var label = expected . label ;
151
136
@@ -181,7 +166,11 @@ describe('Test hover and click interactions', function() {
181
166
. then ( _hover )
182
167
. then ( function ( eventData ) {
183
168
assertEventData ( eventData , expected ) ;
184
- assertHoverLabelStyle ( d3 . select ( 'g.hovertext' ) , expected , opts . msg ) ;
169
+ var g = d3 . select ( 'g.hovertext' ) ;
170
+ if ( g . node ( ) === null ) {
171
+ expect ( expected . noHoverLabel ) . toBe ( true ) ;
172
+ }
173
+ else assertHoverLabelStyle ( g , expected , opts . msg ) ;
185
174
assertHoveLabelContent ( expected ) ;
186
175
} )
187
176
. then ( _click )
@@ -225,8 +214,8 @@ describe('Test hover and click interactions', function() {
225
214
label : [ '0.387' ] ,
226
215
curveNumber : 0 ,
227
216
pointNumber : 33 ,
228
- bgColor : 'rgb(0, 0, 255)' ,
229
- borderColor : 'rgb(255, 0, 0)' ,
217
+ bgcolor : 'rgb(0, 0, 255)' ,
218
+ bordercolor : 'rgb(255, 0, 0)' ,
230
219
fontSize : 20 ,
231
220
fontFamily : 'Arial' ,
232
221
fontColor : 'rgb(255, 255, 0)'
@@ -273,8 +262,8 @@ describe('Test hover and click interactions', function() {
273
262
y : 9 ,
274
263
curveNumber : 2 ,
275
264
pointNumber : 1 ,
276
- bgColor : 'rgb(0, 128, 0)' ,
277
- borderColor : 'rgb(255, 255, 255)' ,
265
+ bgcolor : 'rgb(0, 128, 0)' ,
266
+ bordercolor : 'rgb(255, 255, 255)' ,
278
267
fontSize : 8 ,
279
268
fontFamily : 'Arial' ,
280
269
fontColor : 'rgb(255, 255, 255)'
@@ -305,8 +294,8 @@ describe('Test hover and click interactions', function() {
305
294
y : 3 ,
306
295
curveNumber : 0 ,
307
296
pointNumber : [ 3 , 3 ] ,
308
- bgColor : 'rgb(68, 68, 68)' ,
309
- borderColor : 'rgb(255, 255, 255)' ,
297
+ bgcolor : 'rgb(68, 68, 68)' ,
298
+ bordercolor : 'rgb(255, 255, 255)' ,
310
299
fontSize : 20 ,
311
300
fontFamily : 'Roboto' ,
312
301
fontColor : 'rgb(255, 255, 255)'
@@ -338,8 +327,8 @@ describe('Test hover and click interactions', function() {
338
327
y : 1 ,
339
328
curveNumber : 0 ,
340
329
pointNumber : [ 1 , 2 ] ,
341
- bgColor : 'rgb(0, 0, 0)' ,
342
- borderColor : 'rgb(255, 255, 255)' ,
330
+ bgcolor : 'rgb(0, 0, 0)' ,
331
+ bordercolor : 'rgb(255, 255, 255)' ,
343
332
fontSize : 13 ,
344
333
fontFamily : 'Arial' ,
345
334
fontColor : 'rgb(255, 255, 255)'
@@ -362,8 +351,8 @@ describe('Test hover and click interactions', function() {
362
351
y : 18 ,
363
352
curveNumber : 2 ,
364
353
pointNumber : 0 ,
365
- bgColor : 'rgb(44, 160, 44)' ,
366
- borderColor : 'rgb(255, 255, 255)' ,
354
+ bgcolor : 'rgb(44, 160, 44)' ,
355
+ bordercolor : 'rgb(255, 255, 255)' ,
367
356
fontSize : 13 ,
368
357
fontFamily : 'Arial' ,
369
358
fontColor : 'rgb(255, 255, 255)'
@@ -377,8 +366,8 @@ describe('Test hover and click interactions', function() {
377
366
y : 18 ,
378
367
curveNumber : 2 ,
379
368
pointNumber : 0 ,
380
- bgColor : 'rgb(255, 127, 14)' ,
381
- borderColor : 'rgb(68, 68, 68)' ,
369
+ bgcolor : 'rgb(255, 127, 14)' ,
370
+ bordercolor : 'rgb(68, 68, 68)' ,
382
371
fontSize : 13 ,
383
372
fontFamily : 'Arial' ,
384
373
fontColor : 'rgb(68, 68, 68)'
@@ -407,8 +396,8 @@ describe('Test hover and click interactions', function() {
407
396
y : 18 ,
408
397
curveNumber : 2 ,
409
398
pointNumber : 0 ,
410
- bgColor : 'rgb(44, 160, 44)' ,
411
- borderColor : 'rgb(255, 255, 255)' ,
399
+ bgcolor : 'rgb(44, 160, 44)' ,
400
+ bordercolor : 'rgb(255, 255, 255)' ,
412
401
fontSize : 13 ,
413
402
fontFamily : 'Arial' ,
414
403
fontColor : 'rgb(255, 255, 255)'
@@ -425,8 +414,8 @@ describe('Test hover and click interactions', function() {
425
414
y : 18 ,
426
415
curveNumber : 2 ,
427
416
pointNumber : 0 ,
428
- bgColor : 'rgb(255, 127, 14)' ,
429
- borderColor : 'rgb(68, 68, 68)' ,
417
+ bgcolor : 'rgb(255, 127, 14)' ,
418
+ bordercolor : 'rgb(68, 68, 68)' ,
430
419
fontSize : 13 ,
431
420
fontFamily : 'Arial' ,
432
421
fontColor : 'rgb(68, 68, 68)'
@@ -456,8 +445,8 @@ describe('Test hover and click interactions', function() {
456
445
y : 3 ,
457
446
curveNumber : 0 ,
458
447
pointNumber : [ 3 , 3 ] ,
459
- bgColor : 'rgb(68, 68, 68)' ,
460
- borderColor : 'rgb(255, 255, 255)' ,
448
+ bgcolor : 'rgb(68, 68, 68)' ,
449
+ bordercolor : 'rgb(255, 255, 255)' ,
461
450
fontSize : 20 ,
462
451
fontFamily : 'Arial' ,
463
452
fontColor : 'rgb(255, 255, 255)'
0 commit comments