Skip to content

Commit ff5db2b

Browse files
committed
add new hover tests
1 parent 749430d commit ff5db2b

File tree

1 file changed

+138
-0
lines changed

1 file changed

+138
-0
lines changed

test/jasmine/tests/hover_label_test.js

+138
Original file line numberDiff line numberDiff line change
@@ -2778,6 +2778,75 @@ describe('Hover on axes with rangebreaks', function() {
27782778
.then(done);
27792779
});
27802780

2781+
it('should work when rangebreaks are present on x-axis (reversed range)', function(done) {
2782+
Plotly.plot(gd, [{
2783+
mode: 'lines', // i.e. no autorange padding
2784+
x: [
2785+
'1970-01-01 00:00:00.000',
2786+
'1970-01-01 00:00:00.010',
2787+
'1970-01-01 00:00:00.050',
2788+
'1970-01-01 00:00:00.090',
2789+
'1970-01-01 00:00:00.095',
2790+
'1970-01-01 00:00:00.100',
2791+
'1970-01-01 00:00:00.150',
2792+
'1970-01-01 00:00:00.190',
2793+
'1970-01-01 00:00:00.200'
2794+
]
2795+
}], {
2796+
xaxis: {
2797+
autorange: 'reversed',
2798+
rangebreaks: [
2799+
{bounds: [
2800+
'1970-01-01 00:00:00.011',
2801+
'1970-01-01 00:00:00.089'
2802+
]},
2803+
{bounds: [
2804+
'1970-01-01 00:00:00.101',
2805+
'1970-01-01 00:00:00.189'
2806+
]}
2807+
]
2808+
},
2809+
width: 400,
2810+
height: 400,
2811+
margin: {l: 10, t: 10, b: 10, r: 10},
2812+
hovermode: 'x'
2813+
})
2814+
.then(function() {
2815+
gd.on('plotly_hover', function(d) {
2816+
eventData = d.points[0];
2817+
});
2818+
})
2819+
.then(function() { _hover(11, 11); })
2820+
.then(function() {
2821+
_assert('leftmost interval', {
2822+
nums: '8',
2823+
axis: 'Jan 1, 1970, 00:00:00.2',
2824+
x: '1970-01-01 00:00:00.2',
2825+
y: 8
2826+
});
2827+
})
2828+
.then(function() { _hover(200, 200); })
2829+
.then(function() {
2830+
_assert('middle interval', {
2831+
nums: '4',
2832+
axis: 'Jan 1, 1970, 00:00:00.095',
2833+
x: '1970-01-01 00:00:00.095',
2834+
y: 4
2835+
});
2836+
})
2837+
.then(function() { _hover(388, 388); })
2838+
.then(function() {
2839+
_assert('rightmost interval', {
2840+
nums: '0',
2841+
axis: 'Jan 1, 1970',
2842+
x: '1970-01-01',
2843+
y: 0
2844+
});
2845+
})
2846+
.catch(failTest)
2847+
.then(done);
2848+
});
2849+
27812850
it('should work when rangebreaks are present on y-axis using hovermode x (case of bar and autorange reversed)', function(done) {
27822851
Plotly.plot(gd, [{
27832852
type: 'bar',
@@ -2924,6 +2993,75 @@ describe('Hover on axes with rangebreaks', function() {
29242993
.catch(failTest)
29252994
.then(done);
29262995
});
2996+
2997+
it('should work when rangebreaks are present on y-axis (reversed range)', function(done) {
2998+
Plotly.plot(gd, [{
2999+
mode: 'lines', // i.e. no autorange padding
3000+
y: [
3001+
'1970-01-01 00:00:00.000',
3002+
'1970-01-01 00:00:00.010',
3003+
'1970-01-01 00:00:00.050',
3004+
'1970-01-01 00:00:00.090',
3005+
'1970-01-01 00:00:00.095',
3006+
'1970-01-01 00:00:00.100',
3007+
'1970-01-01 00:00:00.150',
3008+
'1970-01-01 00:00:00.190',
3009+
'1970-01-01 00:00:00.200'
3010+
]
3011+
}], {
3012+
yaxis: {
3013+
autorange: 'reversed',
3014+
rangebreaks: [
3015+
{bounds: [
3016+
'1970-01-01 00:00:00.011',
3017+
'1970-01-01 00:00:00.089'
3018+
]},
3019+
{bounds: [
3020+
'1970-01-01 00:00:00.101',
3021+
'1970-01-01 00:00:00.189'
3022+
]}
3023+
]
3024+
},
3025+
width: 400,
3026+
height: 400,
3027+
margin: {l: 10, t: 10, b: 10, r: 10},
3028+
hovermode: 'y'
3029+
})
3030+
.then(function() {
3031+
gd.on('plotly_hover', function(d) {
3032+
eventData = d.points[0];
3033+
});
3034+
})
3035+
.then(function() { _hover(388, 30); })
3036+
.then(function() {
3037+
_assert('topmost interval', {
3038+
nums: '0',
3039+
axis: 'Jan 1, 1970',
3040+
x: 0,
3041+
y: '1970-01-01'
3042+
});
3043+
})
3044+
.then(function() { _hover(200, 200); })
3045+
.then(function() {
3046+
_assert('middle interval', {
3047+
nums: '4',
3048+
axis: 'Jan 1, 1970, 00:00:00.095',
3049+
x: 4,
3050+
y: '1970-01-01 00:00:00.095'
3051+
});
3052+
})
3053+
.then(function() { _hover(11, 370); })
3054+
.then(function() {
3055+
_assert('bottom interval', {
3056+
nums: '8',
3057+
axis: 'Jan 1, 1970, 00:00:00.2',
3058+
x: 8,
3059+
y: '1970-01-01 00:00:00.2'
3060+
});
3061+
})
3062+
.catch(failTest)
3063+
.then(done);
3064+
});
29273065
});
29283066

29293067
describe('hover updates', function() {

0 commit comments

Comments
 (0)