Skip to content

Commit 1ab4e1a

Browse files
committed
jasmine test
1 parent 0eaec35 commit 1ab4e1a

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

test/jasmine/tests/hover_label_test.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2445,6 +2445,12 @@ describe('hover on subplots when hoversubplots is set to *single* and x hovermod
24452445
});
24462446
});
24472447

2448+
function assertFirstPointOn(gd, xaxisId, yaxisId) {
2449+
// first point should be on the main subplot
2450+
expect(gd._hoverdata[0].xaxis._id).toBe(xaxisId);
2451+
expect(gd._hoverdata[0].yaxis._id).toBe(yaxisId);
2452+
}
2453+
24482454
describe('hover on subplots when hoversubplots is set to *axis* and x hovermodes', function() {
24492455
'use strict';
24502456

@@ -2494,6 +2500,9 @@ describe('hover on subplots when hoversubplots is set to *axis* and x hovermodes
24942500
Lib.clearThrottle();
24952501
Plotly.Fx.hover(gd, {xval: pos}, subplot);
24962502
expect(gd._hoverdata.length).toBe(3);
2503+
2504+
assertFirstPointOn(gd, 'x', 'y');
2505+
24972506
assertHoverLabelContent({
24982507
nums: ['1', '10', '100'],
24992508
name: ['trace 0', 'trace 1', 'trace 2'],
@@ -2505,6 +2514,8 @@ describe('hover on subplots when hoversubplots is set to *axis* and x hovermodes
25052514
Lib.clearThrottle();
25062515
Plotly.Fx.hover(gd, {xval: pos}, subplot);
25072516

2517+
assertFirstPointOn(gd, 'x', 'y2');
2518+
25082519
expect(gd._hoverdata.length).toBe(3);
25092520
assertHoverLabelContent({
25102521
nums: ['2', '20', '200'],
@@ -2517,6 +2528,8 @@ describe('hover on subplots when hoversubplots is set to *axis* and x hovermodes
25172528
Lib.clearThrottle();
25182529
Plotly.Fx.hover(gd, {xval: pos}, subplot);
25192530

2531+
assertFirstPointOn(gd, 'x', 'y3');
2532+
25202533
expect(gd._hoverdata.length).toBe(3);
25212534
assertHoverLabelContent({
25222535
nums: ['3', '30', '300'],
@@ -2530,6 +2543,8 @@ describe('hover on subplots when hoversubplots is set to *axis* and x hovermodes
25302543
Lib.clearThrottle();
25312544
Plotly.Fx.hover(gd, {xval: pos}, subplot);
25322545
expect(gd._hoverdata.length).toBe(3);
2546+
2547+
assertFirstPointOn(gd, 'x', 'y');
25332548
});
25342549
});
25352550

@@ -2582,6 +2597,9 @@ describe('hover on subplots when hoversubplots is set to *axis* and y hovermodes
25822597
Lib.clearThrottle();
25832598
Plotly.Fx.hover(gd, {yval: pos}, subplot);
25842599
expect(gd._hoverdata.length).toBe(3);
2600+
2601+
assertFirstPointOn(gd, 'x', 'y');
2602+
25852603
assertHoverLabelContent({
25862604
nums: ['1', '10', '100'],
25872605
name: ['trace 0', 'trace 1', 'trace 2'],
@@ -2594,6 +2612,9 @@ describe('hover on subplots when hoversubplots is set to *axis* and y hovermodes
25942612
Plotly.Fx.hover(gd, {yval: pos}, subplot);
25952613

25962614
expect(gd._hoverdata.length).toBe(3);
2615+
2616+
assertFirstPointOn(gd, 'x2', 'y');
2617+
25972618
assertHoverLabelContent({
25982619
nums: ['2', '20', '200'],
25992620
name: ['trace 0', 'trace 1', 'trace 2'],
@@ -2606,6 +2627,9 @@ describe('hover on subplots when hoversubplots is set to *axis* and y hovermodes
26062627
Plotly.Fx.hover(gd, {yval: pos}, subplot);
26072628

26082629
expect(gd._hoverdata.length).toBe(3);
2630+
2631+
assertFirstPointOn(gd, 'x3', 'y');
2632+
26092633
assertHoverLabelContent({
26102634
nums: ['3', '30', '300'],
26112635
name: ['trace 0', 'trace 1', 'trace 2'],
@@ -2618,6 +2642,8 @@ describe('hover on subplots when hoversubplots is set to *axis* and y hovermodes
26182642
Lib.clearThrottle();
26192643
Plotly.Fx.hover(gd, {yval: pos}, subplot);
26202644
expect(gd._hoverdata.length).toBe(3);
2645+
2646+
assertFirstPointOn(gd, 'x', 'y');
26212647
});
26222648
});
26232649

@@ -2641,6 +2667,9 @@ describe('splom hover on subplots when hoversubplots is set to *axis* and (x|y)
26412667
Lib.clearThrottle();
26422668
Plotly.Fx.hover(gd, {x: 200, y: 200}, 'xy');
26432669
expect(gd._hoverdata.length).toBe(3);
2670+
2671+
assertFirstPointOn(gd, 'x', 'y');
2672+
26442673
assertHoverLabelContent({
26452674
nums: ['100', '100k'],
26462675
name: ['', ''],
@@ -2651,11 +2680,17 @@ describe('splom hover on subplots when hoversubplots is set to *axis* and (x|y)
26512680

26522681
Lib.clearThrottle();
26532682
Plotly.Fx.hover(gd, {x: 200, y: 200}, 'xy');
2683+
2684+
assertFirstPointOn(gd, 'x', 'y');
2685+
26542686
expect(gd._hoverdata.length).toBe(3);
26552687

26562688
Plotly.relayout(gd, 'hovermode', 'y unified');
26572689
Lib.clearThrottle();
26582690
Plotly.Fx.hover(gd, {x: 200, y: 200}, 'xy');
2691+
2692+
assertFirstPointOn(gd, 'x', 'y');
2693+
26592694
expect(gd._hoverdata.length).toBe(3);
26602695
});
26612696
});
@@ -2697,6 +2732,9 @@ describe('splom hover *axis* hoversubplots splom points on same position should
26972732
Lib.clearThrottle();
26982733
Plotly.Fx.hover(gd, {}, 'xy');
26992734
expect(gd._hoverdata.length).toBe(5);
2735+
2736+
assertFirstPointOn(gd, 'x', 'y');
2737+
27002738
assertHoverLabelContent({
27012739
nums: ['1', '1', '1', '1'],
27022740
name: ['', '', '', ''],
@@ -2706,6 +2744,9 @@ describe('splom hover *axis* hoversubplots splom points on same position should
27062744
Lib.clearThrottle();
27072745
Plotly.Fx.hover(gd, {}, 'xy2');
27082746
expect(gd._hoverdata.length).toBe(4);
2747+
2748+
assertFirstPointOn(gd, 'x', 'y2');
2749+
27092750
assertHoverLabelContent({
27102751
nums: ['1', '2', '2'],
27112752
name: ['', '', ''],
@@ -2715,6 +2756,9 @@ describe('splom hover *axis* hoversubplots splom points on same position should
27152756
Lib.clearThrottle();
27162757
Plotly.Fx.hover(gd, {}, 'xy3');
27172758
expect(gd._hoverdata.length).toBe(4);
2759+
2760+
assertFirstPointOn(gd, 'x', 'y3');
2761+
27182762
assertHoverLabelContent({
27192763
nums: ['1', '2', '2'],
27202764
name: ['', '', ''],
@@ -2724,6 +2768,9 @@ describe('splom hover *axis* hoversubplots splom points on same position should
27242768
Lib.clearThrottle();
27252769
Plotly.Fx.hover(gd, {}, 'xy4');
27262770
expect(gd._hoverdata.length).toBe(5);
2771+
2772+
assertFirstPointOn(gd, 'x', 'y4');
2773+
27272774
assertHoverLabelContent({
27282775
nums: ['1', '3', '3', '3'],
27292776
name: ['', '', '', ''],
@@ -2733,6 +2780,9 @@ describe('splom hover *axis* hoversubplots splom points on same position should
27332780
Lib.clearThrottle();
27342781
Plotly.Fx.hover(gd, {}, 'x2y');
27352782
expect(gd._hoverdata.length).toBe(5);
2783+
2784+
assertFirstPointOn(gd, 'x2', 'y');
2785+
27362786
assertHoverLabelContent({
27372787
nums: ['1', '3', '3', '3'],
27382788
name: ['', '', '', ''],
@@ -2742,6 +2792,9 @@ describe('splom hover *axis* hoversubplots splom points on same position should
27422792
Lib.clearThrottle();
27432793
Plotly.Fx.hover(gd, {}, 'x3y');
27442794
expect(gd._hoverdata.length).toBe(5);
2795+
2796+
assertFirstPointOn(gd, 'x3', 'y');
2797+
27452798
assertHoverLabelContent({
27462799
nums: ['1', '3', '3', '3'],
27472800
name: ['', '', '', ''],
@@ -2751,6 +2804,9 @@ describe('splom hover *axis* hoversubplots splom points on same position should
27512804
Lib.clearThrottle();
27522805
Plotly.Fx.hover(gd, {}, 'x4y');
27532806
expect(gd._hoverdata.length).toBe(5);
2807+
2808+
assertFirstPointOn(gd, 'x4', 'y');
2809+
27542810
assertHoverLabelContent({
27552811
nums: ['1', '3', '3', '3'],
27562812
name: ['', '', '', ''],

0 commit comments

Comments
 (0)