Skip to content

Commit f459b5c

Browse files
committed
add ternary drag test (including staticPlot case)
1 parent fa92af2 commit f459b5c

File tree

1 file changed

+45
-4
lines changed

1 file changed

+45
-4
lines changed

test/jasmine/tests/ternary_test.js

+45-4
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,46 @@ describe('ternary plots', function() {
186186
it('should respond zoom drag interactions', function(done) {
187187
assertRange(gd, [0.231, 0.2, 0.11]);
188188

189-
Plotly.relayout(gd, 'ternary.aaxis.min', 0.1).then(function() {
190-
assertRange(gd, [0.1, 0.2, 0.11]);
189+
drag([[390, 220], [300, 250]]);
190+
assertRange(gd, [0.4486, 0.2480, 0.1453]);
191191

192-
return doubleClick(pointPos[0], pointPos[1]);
193-
}).then(function() {
192+
doubleClick(pointPos[0], pointPos[1]).then(function() {
194193
assertRange(gd, [0, 0, 0]);
195194

196195
done();
197196
});
198197
});
199198
});
200199

200+
describe('static plots', function() {
201+
var mock = require('@mocks/ternary_simple.json');
202+
var gd;
203+
204+
beforeEach(function(done) {
205+
gd = createGraphDiv();
206+
207+
var mockCopy = Lib.extendDeep({}, mock);
208+
var config = { staticPlot: true };
209+
210+
Plotly.plot(gd, mockCopy.data, mockCopy.layout, config).then(done);
211+
});
212+
213+
it('should not respond to drag', function(done) {
214+
var range = [0.231, 0.2, 0.11];
215+
216+
assertRange(gd, range);
217+
218+
drag([[390, 220], [300, 250]]);
219+
assertRange(gd, range);
220+
221+
doubleClick(390, 220).then(function() {
222+
assertRange(gd, range);
223+
224+
done();
225+
});
226+
});
227+
});
228+
201229
function countTernarySubplot() {
202230
return d3.selectAll('.ternary').size();
203231
}
@@ -227,6 +255,19 @@ describe('ternary plots', function() {
227255
});
228256
}
229257

258+
function drag(path) {
259+
var len = path.length;
260+
261+
mouseEvent('mousemove', path[0][0], path[0][1]);
262+
mouseEvent('mousedown', path[0][0], path[0][1]);
263+
264+
path.slice(1, len).forEach(function(pt) {
265+
mouseEvent('mousemove', pt[0], pt[1]);
266+
});
267+
268+
mouseEvent('mouseup', path[len - 1][0], path[len - 1][1]);
269+
}
270+
230271
function assertRange(gd, expected) {
231272
var ternary = gd._fullLayout.ternary;
232273
var actual = [

0 commit comments

Comments
 (0)