@@ -1274,7 +1274,7 @@ describe('hover updates', function() {
1274
1274
1275
1275
afterEach ( destroyGraphDiv ) ;
1276
1276
1277
- function assertLabelsCorrect ( mousePos , labelPos , labelText ) {
1277
+ function assertLabelsCorrect ( mousePos , labelPos , labelText , msg ) {
1278
1278
return new Promise ( function ( resolve ) {
1279
1279
if ( mousePos ) {
1280
1280
mouseEvent ( 'mousemove' , mousePos [ 0 ] , mousePos [ 1 ] ) ;
@@ -1283,14 +1283,14 @@ describe('hover updates', function() {
1283
1283
setTimeout ( function ( ) {
1284
1284
var hoverText = d3 . selectAll ( 'g.hovertext' ) ;
1285
1285
if ( labelPos ) {
1286
- expect ( hoverText . size ( ) ) . toEqual ( 1 ) ;
1287
- expect ( hoverText . text ( ) ) . toEqual ( labelText ) ;
1286
+ expect ( hoverText . size ( ) ) . toBe ( 1 , msg ) ;
1287
+ expect ( hoverText . text ( ) ) . toBe ( labelText , msg ) ;
1288
1288
1289
1289
var transformParts = hoverText . attr ( 'transform' ) . split ( '(' ) ;
1290
- expect ( transformParts [ 0 ] ) . toEqual ( 'translate' ) ;
1290
+ expect ( transformParts [ 0 ] ) . toBe ( 'translate' , msg ) ;
1291
1291
var transformCoords = transformParts [ 1 ] . split ( ')' ) [ 0 ] . split ( ',' ) ;
1292
- expect ( + transformCoords [ 0 ] ) . toBeCloseTo ( labelPos [ 0 ] , - 1 , labelText + ':x' ) ;
1293
- expect ( + transformCoords [ 1 ] ) . toBeCloseTo ( labelPos [ 1 ] , - 1 , labelText + ':y' ) ;
1292
+ expect ( + transformCoords [ 0 ] ) . toBeCloseTo ( labelPos [ 0 ] , - 1 , labelText + ':x ' + msg ) ;
1293
+ expect ( + transformCoords [ 1 ] ) . toBeCloseTo ( labelPos [ 1 ] , - 1 , labelText + ':y ' + msg ) ;
1294
1294
} else {
1295
1295
expect ( hoverText . size ( ) ) . toEqual ( 0 ) ;
1296
1296
}
@@ -1318,7 +1318,7 @@ describe('hover updates', function() {
1318
1318
var gd = createGraphDiv ( ) ;
1319
1319
Plotly . plot ( gd , mock ) . then ( function ( ) {
1320
1320
// The label text gets concatenated together when queried. Such is life.
1321
- return assertLabelsCorrect ( [ 100 , 100 ] , [ 103 , 100 ] , 'trace 00.5' ) ;
1321
+ return assertLabelsCorrect ( [ 100 , 100 ] , [ 103 , 100 ] , 'trace 00.5' , 'animation/update 0' ) ;
1322
1322
} ) . then ( function ( ) {
1323
1323
return Plotly . animate ( gd , [ {
1324
1324
data : [ { x : [ 0 ] , y : [ 0 ] } , { x : [ 0.5 ] , y : [ 0.5 ] } ] ,
@@ -1327,25 +1327,25 @@ describe('hover updates', function() {
1327
1327
} ) . then ( function ( ) {
1328
1328
// No mouse event this time. Just change the data and check the label.
1329
1329
// Ditto on concatenation. This is "trace 1" + "0.5"
1330
- return assertLabelsCorrect ( null , [ 103 , 100 ] , 'trace 10.5' ) ;
1330
+ return assertLabelsCorrect ( null , [ 103 , 100 ] , 'trace 10.5' , 'animation/update 1' ) ;
1331
1331
} ) . then ( function ( ) {
1332
1332
// Restyle to move the point out of the window:
1333
1333
return Plotly . relayout ( gd , { 'xaxis.range' : [ 2 , 3 ] } ) ;
1334
1334
} ) . then ( function ( ) {
1335
1335
// Assert label removed:
1336
- return assertLabelsCorrect ( null , null ) ;
1336
+ return assertLabelsCorrect ( null , null , null , 'animation/update 2' ) ;
1337
1337
} ) . then ( function ( ) {
1338
1338
// Move back to the original xaxis range:
1339
1339
return Plotly . relayout ( gd , { 'xaxis.range' : [ 0 , 1 ] } ) ;
1340
1340
} ) . then ( function ( ) {
1341
1341
// Assert label restored:
1342
- return assertLabelsCorrect ( null , [ 103 , 100 ] , 'trace 10.5' ) ;
1342
+ return assertLabelsCorrect ( null , [ 103 , 100 ] , 'trace 10.5' , 'animation/update 3' ) ;
1343
1343
} ) . catch ( fail ) . then ( done ) ;
1344
1344
} ) ;
1345
1345
1346
1346
it ( 'should not trigger infinite loop of plotly_unhover events' , function ( done ) {
1347
1347
var gd = createGraphDiv ( ) ;
1348
- var colors0 = [ '#00000 ' , '#00000 ' , '#00000 ' , '#00000 ' , '#00000 ' , '#00000 ' , '#00000 ' ] ;
1348
+ var colors0 = [ '#000000 ' , '#000000 ' , '#000000 ' , '#000000 ' , '#000000 ' , '#000000 ' , '#000000 ' ] ;
1349
1349
1350
1350
function unhover ( ) {
1351
1351
return new Promise ( function ( resolve ) {
@@ -1365,7 +1365,7 @@ describe('hover updates', function() {
1365
1365
y : [ 1 , 2 , 3 , 2 , 3 , 4 , 3 ] ,
1366
1366
marker : {
1367
1367
size : 16 ,
1368
- colors : colors0 . slice ( )
1368
+ color : colors0 . slice ( )
1369
1369
}
1370
1370
} ] )
1371
1371
. then ( function ( ) {
@@ -1383,14 +1383,14 @@ describe('hover updates', function() {
1383
1383
Plotly . restyle ( gd , 'marker.color' , [ colors0 . slice ( ) ] ) ;
1384
1384
} ) ;
1385
1385
1386
- return assertLabelsCorrect ( [ 351 , 251 ] , [ 358 , 272 ] , '2' ) ;
1386
+ return assertLabelsCorrect ( [ 351 , 251 ] , [ 358 , 272 ] , '2' , 'events 0' ) ;
1387
1387
} )
1388
1388
. then ( unhover )
1389
1389
. then ( function ( ) {
1390
1390
expect ( hoverCnt ) . toEqual ( 1 ) ;
1391
1391
expect ( unHoverCnt ) . toEqual ( 1 ) ;
1392
1392
1393
- return assertLabelsCorrect ( [ 400 , 200 ] , [ 435 , 198 ] , '3' ) ;
1393
+ return assertLabelsCorrect ( [ 420 , 100 ] , [ 435 , 198 ] , '3' , 'events 1 ') ;
1394
1394
} )
1395
1395
. then ( unhover )
1396
1396
. then ( function ( ) {
0 commit comments