Skip to content

Commit df48475

Browse files
committed
Test both axes in scatterpolargl to return same select eventData as non-gl
1 parent f2bcff5 commit df48475

File tree

1 file changed

+43
-39
lines changed

1 file changed

+43
-39
lines changed

test/jasmine/tests/scatterpolargl_test.js

+43-39
Original file line numberDiff line numberDiff line change
@@ -298,46 +298,50 @@ describe('Test scatterpolargl interactions:', function() {
298298
.then(done, done.fail);
299299
});
300300

301-
[
302-
['linear', [0, 180]],
303-
['category', ['A', 'B']],
304-
].forEach(function(test) {
305-
var axType = test[0];
306-
var x = test[1];
307-
it('@gl should return the same eventData as scatter on ' + axType + ' axis', function(done) {
308-
var _mock = {
309-
data: [{type: 'scatterpolar', r: [5, 10], theta: x}],
310-
layout: {dragmode: 'select', width: 400, height: 400}
311-
};
312-
gd = createGraphDiv();
313-
var scatterpolarEventData = {};
314-
var selectPath = [[200, 150], [400, 250]];
315-
316-
Plotly.newPlot(gd, _mock)
317-
.then(delay(20))
318-
.then(function() {
319-
expect(gd._fullLayout.polar.angularaxis.type).toEqual(test[0]);
320-
return select(gd, selectPath);
321-
})
322-
.then(delay(20))
323-
.then(function(eventData) {
324-
scatterpolarEventData = eventData;
325-
// Make sure we selected a point
326-
expect(eventData.points.length).toBe(1);
327-
return Plotly.restyle(gd, 'type', 'scatterpolargl');
328-
})
329-
.then(delay(20))
330-
.then(function() {
331-
expect(gd._fullLayout.polar.angularaxis.type).toEqual(test[0]);
332-
return select(gd, selectPath);
333-
})
334-
.then(delay(20))
335-
.then(function(eventData) {
336-
assertEventData(eventData, scatterpolarEventData);
337-
})
338-
.then(done, done.fail);
301+
['r', 'theta'].forEach(function(ax) {
302+
[
303+
['linear', [0, 180]],
304+
['category', ['A', 'B']],
305+
].forEach(function(test) {
306+
var axType = test[0];
307+
var axNames = {'r': 'radialaxis', 'theta': 'angularaxis'};
308+
it('@gl should return the same eventData as scatter on ' + axType + ' ' + ax + ' axis', function(done) {
309+
var _mock = {
310+
data: [{type: 'scatterpolar', r: [5, 10], theta: [0, 180]}],
311+
layout: {dragmode: 'select', width: 400, height: 400}
312+
};
313+
_mock.data[0][ax] = test[1];
314+
gd = createGraphDiv();
315+
var scatterpolarEventData = {};
316+
var selectPath = [[185, 150], [400, 250]];
317+
318+
Plotly.newPlot(gd, _mock)
319+
.then(delay(20))
320+
.then(function() {
321+
expect(gd._fullLayout.polar[axNames[ax]].type).toEqual(test[0]);
322+
return select(gd, selectPath);
323+
})
324+
.then(delay(20))
325+
.then(function(eventData) {
326+
scatterpolarEventData = eventData;
327+
// Make sure we selected a point
328+
expect(eventData.points.length).toBe(1);
329+
return Plotly.restyle(gd, 'type', 'scatterpolargl');
330+
})
331+
.then(delay(20))
332+
.then(function() {
333+
expect(gd._fullLayout.polar[axNames[ax]].type).toEqual(test[0]);
334+
return select(gd, selectPath);
335+
})
336+
.then(delay(20))
337+
.then(function(eventData) {
338+
assertEventData(eventData, scatterpolarEventData);
339+
})
340+
.then(done, done.fail);
341+
});
339342
});
340-
});
343+
})
344+
341345
});
342346

343347
describe('Test scatterpolargl autorange:', function() {

0 commit comments

Comments
 (0)