Skip to content

Commit c49d829

Browse files
committed
Add initial test case
1 parent 2112759 commit c49d829

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

test/jasmine/tests/select_test.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,54 @@ describe('@flaky Test select box and lasso in general:', function() {
552552
.catch(fail)
553553
.then(done);
554554
});
555+
556+
it('should select the right data with the corresponding select direction', function(done) {
557+
558+
var gd = createGraphDiv();
559+
560+
var selectPath = [[170 - 68, 100 - 96], [255 - 68, 160 - 96]];
561+
562+
Plotly.newPlot(gd, [
563+
{x: [1, 1, 1, 1, 1, 2, 2, 2, 3, 3], type: 'histogram'},
564+
{x: [1, 2, 3], y: [-1, -2, -3], type: 'bar'}
565+
], {
566+
width: 400,
567+
height: 300,
568+
showlegend: false,
569+
dragmode: 'select'
570+
})
571+
.then(function() {
572+
573+
// expect(gd.fullLayout.selectdirection).toBe('any');
574+
575+
resetEvents(gd);
576+
577+
drag(selectPath);
578+
579+
selectedPromise.then(function() {
580+
expect(selectedData.points.length).toBe(1);
581+
expect(selectedData.points[0].x).toBe(1.8);
582+
expect(selectedData.points[0].y).toBe(3);
583+
});
584+
585+
// do a drag and check that the selection is correct for the default `selectdirection`
586+
587+
return Plotly.relayout(gd, {selectdirection: 'h'});
588+
})
589+
.then(function() {
590+
// do probably the SAME drag and check that the selection is correct for the `selectdirection='h'`
591+
592+
return Plotly.relayout(gd, {selectdirection: 'v'});
593+
})
594+
.then(function() {
595+
// ...
596+
})
597+
.catch(fail) // hmm, we should change the name of this import to failTest, since fail is already a jasmine global, for sync failure, we're overriding it here with our async version (we've already done this in other places)
598+
.then(done);
599+
600+
601+
});
602+
555603
});
556604

557605
describe('@flaky Test select box and lasso per trace:', function() {

0 commit comments

Comments
 (0)