Skip to content

Commit f2bcff5

Browse files
committed
Test both axes in scattergl to return same select's eventData as scatter
1 parent 4fd7070 commit f2bcff5

File tree

1 file changed

+44
-40
lines changed

1 file changed

+44
-40
lines changed

test/jasmine/tests/scattergl_select_test.js

+44-40
Original file line numberDiff line numberDiff line change
@@ -350,46 +350,50 @@ describe('Test gl2d lasso/select:', function() {
350350
.then(done, done.fail);
351351
});
352352

353-
[
354-
['linear', [1, 2, 3]],
355-
['log', [1, 2, 3]],
356-
['category', ['A', 'B', 'C']],
357-
['date', ['1900-01-01', '2000-01-01', '2100-01-01']]
358-
].forEach(function(test) {
359-
var axType = test[0];
360-
var x = test[1];
361-
it('@gl should return the same eventData as scatter on ' + axType + ' axis', function(done) {
362-
var _mock = {
363-
data: [{type: 'scatter', x: x, y: [6, 5, 4]}],
364-
layout: {dragmode: 'select', width: 400, height: 400, xaxis: {type: axType}}
365-
};
366-
gd = createGraphDiv();
367-
var scatterEventData = {};
368-
var selectPath = [[150, 150], [250, 250]];
369-
370-
Plotly.newPlot(gd, _mock)
371-
.then(delay(20))
372-
.then(function() {
373-
expect(gd._fullLayout.xaxis.type).toEqual(test[0]);
374-
return select(gd, selectPath);
375-
})
376-
.then(delay(20))
377-
.then(function(eventData) {
378-
scatterEventData = eventData;
379-
// Make sure we selected a point
380-
expect(eventData.points.length).toBe(1);
381-
return Plotly.restyle(gd, 'type', 'scattergl');
382-
})
383-
.then(delay(20))
384-
.then(function() {
385-
expect(gd._fullLayout.xaxis.type).toEqual(test[0]);
386-
return select(gd, selectPath);
387-
})
388-
.then(delay(20))
389-
.then(function(eventData) {
390-
assertEventData(eventData, scatterEventData);
391-
})
392-
.then(done, done.fail);
353+
['x', 'y'].forEach(function(ax) {
354+
[
355+
['linear', [1, 2, 3]],
356+
['log', [1, 2, 3]],
357+
['category', ['A', 'B', 'C']],
358+
['date', ['1900-01-01', '2000-01-01', '2100-01-01']]
359+
].forEach(function(test) {
360+
var axType = test[0];
361+
362+
it('@gl should return the same eventData as scatter on ' + axType + ' ' + ax + ' axis', function(done) {
363+
var _mock = {
364+
data: [{type: 'scatter', x: [1, 2, 3], y: [6, 5, 4]}],
365+
layout: {dragmode: 'select', width: 400, height: 400, xaxis: {}, yaxis: {}}
366+
};
367+
_mock.data[0][ax] = test[1];
368+
_mock.layout[ax + 'axis'].type = axType;
369+
gd = createGraphDiv();
370+
var scatterEventData = {};
371+
var selectPath = [[150, 150], [250, 250]];
372+
373+
Plotly.newPlot(gd, _mock)
374+
.then(delay(20))
375+
.then(function() {
376+
expect(gd._fullLayout[ax + 'axis'].type).toEqual(test[0]);
377+
return select(gd, selectPath);
378+
})
379+
.then(delay(20))
380+
.then(function(eventData) {
381+
scatterEventData = eventData;
382+
// Make sure we selected a point
383+
expect(eventData.points.length).toBe(1);
384+
return Plotly.restyle(gd, 'type', 'scattergl');
385+
})
386+
.then(delay(20))
387+
.then(function() {
388+
expect(gd._fullLayout[ax + 'axis'].type).toEqual(test[0]);
389+
return select(gd, selectPath);
390+
})
391+
.then(delay(20))
392+
.then(function(eventData) {
393+
assertEventData(eventData, scatterEventData);
394+
})
395+
.then(done, done.fail);
396+
});
393397
});
394398
});
395399
});

0 commit comments

Comments
 (0)