Skip to content

Commit 105bed9

Browse files
committed
Update select_test.js
* Test that a double click removes a selection.
1 parent b7de50f commit 105bed9

File tree

1 file changed

+56
-32
lines changed

1 file changed

+56
-32
lines changed

test/jasmine/tests/select_test.js

+56-32
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,40 @@ describe('select box and lasso', function() {
6868
.then(done);
6969
});
7070

71-
it('should be appended to the zoom layer', function() {
72-
var x0 = 100;
73-
var y0 = 200;
74-
var x1 = 150;
75-
var y1 = 200;
71+
it('should be appended to the zoom layer', function(done) {
72+
var x0 = 100,
73+
y0 = 200,
74+
x1 = 150,
75+
y1 = 250,
76+
x2 = 50,
77+
y2 = 50;
78+
79+
gd.once('plotly_selecting', function() {
80+
expect(d3.selectAll('.zoomlayer > .zoombox-corners').size())
81+
.toEqual(1);
82+
expect(d3.selectAll('.zoomlayer > .select-outline').size())
83+
.toEqual(2);
84+
});
85+
86+
gd.once('plotly_selected', function() {
87+
expect(d3.selectAll('.zoomlayer > .zoombox-corners').size())
88+
.toEqual(0);
89+
expect(d3.selectAll('.zoomlayer > .select-outline').size())
90+
.toEqual(2);
91+
});
92+
93+
gd.once('plotly_deselect', function() {
94+
expect(d3.selectAll('.zoomlayer > .select-outline').size())
95+
.toEqual(0);
96+
});
7697

7798
mouseEvent('mousemove', x0, y0);
7899
expect(d3.selectAll('.zoomlayer > .zoombox-corners').size())
79100
.toEqual(0);
80101

81-
mouseEvent('mousedown', x0, y0);
82-
mouseEvent('mousemove', x1, y1);
83-
expect(d3.selectAll('.zoomlayer > .zoombox-corners').size())
84-
.toEqual(1);
85-
expect(d3.selectAll('.zoomlayer > .select-outline').size())
86-
.toEqual(2);
102+
drag([[x0, y0], [x1, y1]]);
87103

88-
mouseEvent('mouseup', x1, y1);
89-
expect(d3.selectAll('.zoomlayer > .zoombox-corners').size())
90-
.toEqual(0);
91-
expect(d3.selectAll('.zoomlayer > .select-outline').size())
92-
.toEqual(2);
104+
doubleClick(x2, y2, done);
93105
});
94106
});
95107

@@ -105,28 +117,40 @@ describe('select box and lasso', function() {
105117
.then(done);
106118
});
107119

108-
it('should be appended to the zoom layer', function() {
109-
var x0 = 100;
110-
var y0 = 200;
111-
var x1 = 150;
112-
var y1 = 200;
120+
it('should be appended to the zoom layer', function(done) {
121+
var x0 = 100,
122+
y0 = 200,
123+
x1 = 150,
124+
y1 = 250,
125+
x2 = 50,
126+
y2 = 50;
127+
128+
gd.once('plotly_selecting', function() {
129+
expect(d3.selectAll('.zoomlayer > .zoombox-corners').size())
130+
.toEqual(1);
131+
expect(d3.selectAll('.zoomlayer > .select-outline').size())
132+
.toEqual(2);
133+
});
134+
135+
gd.once('plotly_selected', function() {
136+
expect(d3.selectAll('.zoomlayer > .zoombox-corners').size())
137+
.toEqual(0);
138+
expect(d3.selectAll('.zoomlayer > .select-outline').size())
139+
.toEqual(2);
140+
});
141+
142+
gd.once('plotly_deselect', function() {
143+
expect(d3.selectAll('.zoomlayer > .select-outline').size())
144+
.toEqual(0);
145+
});
113146

114147
mouseEvent('mousemove', x0, y0);
115148
expect(d3.selectAll('.zoomlayer > .zoombox-corners').size())
116149
.toEqual(0);
117150

118-
mouseEvent('mousedown', x0, y0);
119-
mouseEvent('mousemove', x1, y1);
120-
expect(d3.selectAll('.zoomlayer > .zoombox-corners').size())
121-
.toEqual(1);
122-
expect(d3.selectAll('.zoomlayer > .select-outline').size())
123-
.toEqual(2);
151+
drag([[x0, y0], [x1, y1]]);
124152

125-
mouseEvent('mouseup', x1, y1);
126-
expect(d3.selectAll('.zoomlayer > .zoombox-corners').size())
127-
.toEqual(0);
128-
expect(d3.selectAll('.zoomlayer > .select-outline').size())
129-
.toEqual(2);
153+
doubleClick(x2, y2, done);
130154
});
131155
});
132156

0 commit comments

Comments
 (0)