Skip to content

Commit

Permalink
extend choropleth tests to include translate3d transform (plotly#5525)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaVazz committed Apr 22, 2021
1 parent 341963e commit 74e706c
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions test/jasmine/tests/choropleth_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ describe('Test choropleth hover:', function() {

function run(hasCssTransform, pos, fig, content, style) {
gd = createGraphDiv();
var scale = 1;

style = style || {
bgcolor: 'rgb(68, 68, 68)',
Expand All @@ -177,14 +176,8 @@ describe('Test choropleth hover:', function() {
fontFamily: 'Arial'
};

return Plotly.newPlot(gd, fig)
.then(function() {
if(hasCssTransform) {
scale = 0.5;
transformPlot(gd, 'translate(-25%, -25%) scale(0.5)');
}

mouseEvent('mousemove', scale * pos[0], scale * pos[1]);
function assertHoverLabel(posX, posY) {
mouseEvent('mousemove', posX, posY);
assertHoverLabelContent({
nums: content[0],
name: content[1]
Expand All @@ -193,6 +186,18 @@ describe('Test choropleth hover:', function() {
d3Select('g.hovertext'),
style
);
}

return Plotly.newPlot(gd, fig)
.then(function() {
if(hasCssTransform) {
transformPlot(gd, 'translate3d(10px, 10px, 0) scale(1)');
assertHoverLabel(pos[0] + 10, pos[1] + 10)
transformPlot(gd, 'translate(-25%, -25%) scale(0.5)');
assertHoverLabel(0.5 * pos[0], 0.5 * pos[1])
} else {
assertHoverLabel(pos[0], pos[1])
}
});
}

Expand Down Expand Up @@ -353,6 +358,9 @@ describe('Test choropleth hover:', function() {
fig.data[0].hovertemplate = '%{properties.name}<extra>%{ct[0]:.1f} | %{ct[1]:.1f}</extra>';
fig.layout.geo.projection = {scale: 20};

if(hasCssTransform) {
debugger
}
run(hasCssTransform, [300, 200], fig, ['New York', '-75.1 | 42.6'])
.then(done, done.fail);
});
Expand Down

0 comments on commit 74e706c

Please sign in to comment.