Skip to content

Commit ef65b9f

Browse files
committed
add jasmine tests
1 parent 428e248 commit ef65b9f

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

test/jasmine/tests/hover_label_test.js

+145
Original file line numberDiff line numberDiff line change
@@ -4998,6 +4998,151 @@ describe('hovermode: (x|y)unified', function() {
49984998
.then(done, done.fail);
49994999
});
50005000

5001+
it('non-period points winning hover', function(done) {
5002+
Plotly.newPlot(gd, {
5003+
data: [
5004+
{
5005+
name: 'bar',
5006+
type: 'bar',
5007+
x: ['1999-12', '2000-01', '2000-02'],
5008+
y: [2, 1, 3],
5009+
xhoverformat: '%b',
5010+
xperiod: 'M1'
5011+
},
5012+
{
5013+
name: 'scatter',
5014+
type: 'scatter',
5015+
x: [
5016+
'2000-01-01', '2000-01-06', '2000-01-11', '2000-01-16', '2000-01-21', '2000-01-26',
5017+
'2000-02-01', '2000-02-06', '2000-02-11', '2000-02-16', '2000-02-21', '2000-02-26',
5018+
'2000-03-01', '2000-03-06', '2000-03-11', '2000-03-16', '2000-03-21', '2000-03-26'
5019+
],
5020+
y: [
5021+
1.1, 1.2, 1.3, 1.4, 1.5, 1.6,
5022+
2.1, 2.2, 2.3, 2.4, 2.5, 2.6,
5023+
3.1, 3.2, 3.3, 3.4, 3.5, 3.6,
5024+
]
5025+
}
5026+
],
5027+
layout: {
5028+
showlegend: false,
5029+
width: 600,
5030+
height: 400,
5031+
hovermode: 'x unified'
5032+
}
5033+
})
5034+
.then(function(gd) {
5035+
_hover(gd, { xpx: 50, ypx: 200 });
5036+
assertLabel({title: 'Dec', items: [
5037+
'bar : 2'
5038+
]});
5039+
5040+
_hover(gd, { xpx: 100, ypx: 200 });
5041+
assertLabel({title: 'Jan 1, 2000', items: [
5042+
'scatter : 1.1'
5043+
]});
5044+
5045+
_hover(gd, { xpx: 150, ypx: 200 });
5046+
assertLabel({title: 'Jan 11, 2000', items: [
5047+
'bar : (Jan, 1)',
5048+
'scatter : 1.3'
5049+
]});
5050+
5051+
_hover(gd, { xpx: 200, ypx: 200 });
5052+
assertLabel({title: 'Jan 26, 2000', items: [
5053+
'bar : (Jan, 1)',
5054+
'scatter : 1.6'
5055+
]});
5056+
5057+
_hover(gd, { xpx: 250, ypx: 200 });
5058+
assertLabel({title: 'Feb 11, 2000', items: [
5059+
'bar : (Feb, 3)',
5060+
'scatter : 2.3'
5061+
]});
5062+
5063+
_hover(gd, { xpx: 300, ypx: 200 });
5064+
assertLabel({title: 'Feb 21, 2000', items: [
5065+
'bar : (Feb, 3)',
5066+
'scatter : 2.5'
5067+
]});
5068+
5069+
_hover(gd, { xpx: 350, ypx: 200 });
5070+
assertLabel({title: 'Mar 6, 2000', items: [
5071+
'scatter : 3.2'
5072+
]});
5073+
})
5074+
.then(done, done.fail);
5075+
});
5076+
5077+
it('period points alignments', function(done) {
5078+
Plotly.newPlot(gd, {
5079+
data: [
5080+
{
5081+
name: 'bar',
5082+
type: 'bar',
5083+
x: ['2000-01', '2000-02'],
5084+
y: [1, 2],
5085+
xhoverfrmat: '%b',
5086+
xperiod: 'M1'
5087+
},
5088+
{
5089+
name: 'start',
5090+
type: 'scatter',
5091+
x: ['2000-01', '2000-02'],
5092+
y: [1, 2],
5093+
xhoverformat: '%b',
5094+
xperiod: 'M1',
5095+
xperiodalignment: 'start'
5096+
},
5097+
{
5098+
name: 'end',
5099+
type: 'scatter',
5100+
x: ['2000-01', '2000-02'],
5101+
y: [1, 2],
5102+
xhoverformat: '%b',
5103+
xperiod: 'M1',
5104+
xperiodalignment: 'end'
5105+
},
5106+
],
5107+
layout: {
5108+
showlegend: false,
5109+
width: 600,
5110+
height: 400,
5111+
hovermode: 'x unified'
5112+
}
5113+
})
5114+
.then(function(gd) {
5115+
_hover(gd, { xpx: 40, ypx: 200 });
5116+
assertLabel({title: 'Jan', items: [
5117+
'bar : (Jan 1, 2000, 1)',
5118+
'start : 1',
5119+
'end : 1'
5120+
]});
5121+
5122+
_hover(gd, { xpx: 100, ypx: 200 });
5123+
assertLabel({title: 'Jan 1, 2000', items: [
5124+
'bar : 1',
5125+
'start : (Jan, 1)',
5126+
'end : (Jan, 1)'
5127+
]});
5128+
5129+
_hover(gd, { xpx: 360, ypx: 200 });
5130+
assertLabel({title: 'Feb 1, 2000', items: [
5131+
'bar : 2',
5132+
'start : (Feb, 2)',
5133+
'end : (Feb, 2)'
5134+
]});
5135+
5136+
_hover(gd, { xpx: 400, ypx: 200 });
5137+
assertLabel({title: 'Feb', items: [
5138+
'bar : (Feb 1, 2000, 2)',
5139+
'start : 2',
5140+
'end : 2'
5141+
]});
5142+
})
5143+
.then(done, done.fail);
5144+
});
5145+
50015146
it('should have the same traceorder as the legend', function(done) {
50025147
var mock = require('@mocks/stacked_area.json');
50035148
var mockCopy = Lib.extendDeep({}, mock);

0 commit comments

Comments
 (0)