Skip to content

Commit 74e706c

Browse files
committed
extend choropleth tests to include translate3d transform (plotly#5525)
1 parent 341963e commit 74e706c

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

test/jasmine/tests/choropleth_test.js

+17-9
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ describe('Test choropleth hover:', function() {
167167

168168
function run(hasCssTransform, pos, fig, content, style) {
169169
gd = createGraphDiv();
170-
var scale = 1;
171170

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

180-
return Plotly.newPlot(gd, fig)
181-
.then(function() {
182-
if(hasCssTransform) {
183-
scale = 0.5;
184-
transformPlot(gd, 'translate(-25%, -25%) scale(0.5)');
185-
}
186-
187-
mouseEvent('mousemove', scale * pos[0], scale * pos[1]);
179+
function assertHoverLabel(posX, posY) {
180+
mouseEvent('mousemove', posX, posY);
188181
assertHoverLabelContent({
189182
nums: content[0],
190183
name: content[1]
@@ -193,6 +186,18 @@ describe('Test choropleth hover:', function() {
193186
d3Select('g.hovertext'),
194187
style
195188
);
189+
}
190+
191+
return Plotly.newPlot(gd, fig)
192+
.then(function() {
193+
if(hasCssTransform) {
194+
transformPlot(gd, 'translate3d(10px, 10px, 0) scale(1)');
195+
assertHoverLabel(pos[0] + 10, pos[1] + 10)
196+
transformPlot(gd, 'translate(-25%, -25%) scale(0.5)');
197+
assertHoverLabel(0.5 * pos[0], 0.5 * pos[1])
198+
} else {
199+
assertHoverLabel(pos[0], pos[1])
200+
}
196201
});
197202
}
198203

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

361+
if(hasCssTransform) {
362+
debugger
363+
}
356364
run(hasCssTransform, [300, 200], fig, ['New York', '-75.1 | 42.6'])
357365
.then(done, done.fail);
358366
});

0 commit comments

Comments
 (0)