Skip to content

Commit 095cef0

Browse files
committed
keep gradual newselection.mode in tests
1 parent fed9db9 commit 095cef0

File tree

3 files changed

+133
-79
lines changed

3 files changed

+133
-79
lines changed

test/jasmine/tests/scattergl_select_test.js

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@ var delay = require('../assets/delay');
1111
var mouseEvent = require('../assets/mouse_event');
1212
var readPixel = require('../assets/read_pixel');
1313

14+
function _newPlot(gd, arg2, arg3, arg4) {
15+
var fig;
16+
if(Array.isArray(arg2)) {
17+
fig = {
18+
data: arg2,
19+
layout: arg3,
20+
config: arg4
21+
};
22+
} else fig = arg2;
23+
24+
if(!fig.layout) fig.layout = {};
25+
if(!fig.layout.newselection) fig.layout.newselection = {};
26+
fig.layout.newselection.mode = 'gradual';
27+
// complex ouline creation are mainly tested in "gradual" mode here
28+
29+
return Plotly.newPlot(gd, fig);
30+
}
31+
1432
function drag(gd, path) {
1533
var len = path.length;
1634
var el = d3Select(gd).select('rect.nsewdrag').node();
@@ -87,7 +105,7 @@ describe('Test gl2d lasso/select:', function() {
87105
_mock.layout.dragmode = 'select';
88106
gd = createGraphDiv();
89107

90-
Plotly.newPlot(gd, _mock)
108+
_newPlot(gd, _mock)
91109
.then(delay(20))
92110
.then(function() {
93111
expect(gd._fullLayout._plots.xy._scene.select2d).not.toBe(undefined, 'scatter2d renderer');
@@ -112,7 +130,7 @@ describe('Test gl2d lasso/select:', function() {
112130
_mock.layout.dragmode = 'lasso';
113131
gd = createGraphDiv();
114132

115-
Plotly.newPlot(gd, _mock)
133+
_newPlot(gd, _mock)
116134
.then(delay(20))
117135
.then(function() {
118136
return select(gd, lassoPath2);
@@ -135,7 +153,7 @@ describe('Test gl2d lasso/select:', function() {
135153
_mock.layout.dragmode = 'select';
136154
gd = createGraphDiv();
137155

138-
Plotly.newPlot(gd, _mock)
156+
_newPlot(gd, _mock)
139157
.then(delay(20))
140158
.then(function() {
141159
return select(gd, selectPath2);
@@ -154,7 +172,7 @@ describe('Test gl2d lasso/select:', function() {
154172
_mock.layout.dragmode = 'lasso';
155173
gd = createGraphDiv();
156174

157-
Plotly.newPlot(gd, _mock)
175+
_newPlot(gd, _mock)
158176
.then(delay(20))
159177
.then(function() {
160178
return select(gd, lassoPath);
@@ -175,7 +193,7 @@ describe('Test gl2d lasso/select:', function() {
175193
fig.layout.width = 500;
176194
gd = createGraphDiv();
177195

178-
Plotly.newPlot(gd, fig)
196+
_newPlot(gd, fig)
179197
.then(delay(20))
180198
.then(function() { return select(gd, [[100, 100], [250, 250]]); })
181199
.then(function(eventData) {
@@ -205,7 +223,7 @@ describe('Test gl2d lasso/select:', function() {
205223
});
206224
}
207225

208-
Plotly.newPlot(gd, fig)
226+
_newPlot(gd, fig)
209227
.then(delay(20))
210228
.then(function() {
211229
_assertGlTextOpts('base', {
@@ -287,7 +305,7 @@ describe('Test gl2d lasso/select:', function() {
287305
});
288306
}
289307

290-
Plotly.newPlot(gd, fig)
308+
_newPlot(gd, fig)
291309
.then(delay(20))
292310
.then(function() {
293311
_assertGlTextOpts('base', {
@@ -370,7 +388,7 @@ describe('Test gl2d lasso/select:', function() {
370388
var scatterEventData = {};
371389
var selectPath = [[150, 150], [250, 250]];
372390

373-
Plotly.newPlot(gd, _mock)
391+
_newPlot(gd, _mock)
374392
.then(delay(20))
375393
.then(function() {
376394
expect(gd._fullLayout[ax + 'axis'].type).toEqual(test[0]);
@@ -428,7 +446,7 @@ describe('Test displayed selections:', function() {
428446

429447
function readFocus() { return _read('.gl-canvas-focus'); }
430448

431-
Plotly.newPlot(gd, [{
449+
_newPlot(gd, [{
432450
type: 'scattergl',
433451
mode: 'markers',
434452
y: [2, 1, 2]
@@ -488,7 +506,7 @@ describe('Test displayed selections:', function() {
488506
}
489507
};
490508

491-
Plotly.newPlot(gd, mock)
509+
_newPlot(gd, mock)
492510
.then(select(gd, [[160, 100], [180, 100]]))
493511
.then(function() {
494512
expect(readPixel(gd.querySelector('.gl-canvas-context'), 168, 100)[3]).toBe(0);
@@ -533,7 +551,7 @@ describe('Test displayed selections:', function() {
533551
}
534552
};
535553

536-
Plotly.newPlot(gd, mock)
554+
_newPlot(gd, mock)
537555
.then(select(gd, [[160, 100], [180, 100]]))
538556
.then(function() {
539557
expect(readPixel(gd.querySelector('.gl-canvas-context'), 168, 100)[3]).toBe(0);
@@ -622,7 +640,7 @@ describe('Test selections during funky scenarios', function() {
622640
it('@gl should behave correctly when doubleclick before selecting anything', function(done) {
623641
gd = createGraphDiv();
624642

625-
Plotly.newPlot(gd, [{
643+
_newPlot(gd, [{
626644
type: 'scattergl',
627645
mode: 'markers',
628646
y: [1, 2, 1],
@@ -678,7 +696,7 @@ describe('Test selections during funky scenarios', function() {
678696
tracker = [];
679697
}
680698

681-
Plotly.newPlot(gd, [{
699+
_newPlot(gd, [{
682700
type: 'scattergl',
683701
mode: 'markers',
684702
y: [1, 2, 1],
@@ -730,7 +748,7 @@ describe('Test selections during funky scenarios', function() {
730748

731749
var scene, scene2;
732750

733-
Plotly.newPlot(gd, [{
751+
_newPlot(gd, [{
734752
x: [1, 2, 3],
735753
y: [40, 50, 60],
736754
type: 'scattergl',

0 commit comments

Comments
 (0)