Skip to content

Commit 76e382e

Browse files
committed
events: move ternary tests to ternary_test.js
1 parent 5cdf009 commit 76e382e

File tree

2 files changed

+214
-214
lines changed

2 files changed

+214
-214
lines changed

test/jasmine/tests/click_test.js

Lines changed: 0 additions & 214 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ var customMatchers = require('../assets/custom_matchers');
1616
var click = require('../assets/click');
1717
var doubleClickRaw = require('../assets/double_click');
1818

19-
20-
function getClientPosition(selector, index) {
21-
index = index || 0;
22-
var selection = document.querySelectorAll(selector),
23-
clientPos = selection[index].getBoundingClientRect(),
24-
x = Math.floor((clientPos.left + clientPos.right) / 2),
25-
y = Math.floor((clientPos.top + clientPos.bottom) / 2);
26-
return [x, y];
27-
}
28-
2919
function move(fromX, fromY, toX, toY, delay) {
3020
return new Promise(function(resolve) {
3121
mouseEvent('mousemove', fromX, fromY);
@@ -928,210 +918,6 @@ describe('Test click interactions:', function() {
928918
});
929919

930920

931-
describe('Test click interactions on a ternary plot:', function() {
932-
var mock = require('@mocks/ternary_simple.json');
933-
934-
var mockCopy, gd;
935-
936-
var blankPos = [10, 10],
937-
pointPos;
938-
939-
beforeAll(function(done) {
940-
jasmine.addMatchers(customMatchers);
941-
942-
gd = createGraphDiv();
943-
mockCopy = Lib.extendDeep({}, mock);
944-
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(function() {
945-
pointPos = getClientPosition('path.point');
946-
destroyGraphDiv();
947-
done();
948-
});
949-
});
950-
951-
beforeEach(function() {
952-
gd = createGraphDiv();
953-
mockCopy = Lib.extendDeep({}, mock);
954-
});
955-
956-
afterEach(destroyGraphDiv);
957-
958-
describe('click events', function() {
959-
var futureData;
960-
961-
beforeEach(function(done) {
962-
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(done);
963-
964-
gd.on('plotly_click', function(data) {
965-
futureData = data;
966-
});
967-
});
968-
969-
it('should not be trigged when not on data points', function() {
970-
click(blankPos[0], blankPos[1]);
971-
expect(futureData).toBe(undefined);
972-
});
973-
974-
it('should contain the correct fields', function() {
975-
click(pointPos[0], pointPos[1]);
976-
977-
var pt = futureData.points[0],
978-
evt = futureData.event;
979-
980-
expect(Object.keys(pt)).toEqual([
981-
'data', 'fullData', 'curveNumber', 'pointNumber', 'x', 'y',
982-
'xaxis', 'yaxis'
983-
]);
984-
985-
expect(pt.curveNumber).toEqual(0, 'points[0].curveNumber');
986-
expect(typeof pt.data).toEqual(typeof {}, 'points[0].data');
987-
expect(typeof pt.fullData).toEqual(typeof {}, 'points[0].fullData');
988-
expect(pt.pointNumber).toEqual(0, 'points[0].pointNumber');
989-
expect(pt.x).toEqual(undefined, 'points[0].x');
990-
expect(pt.y).toEqual(undefined, 'points[0].y');
991-
expect(typeof pt.xaxis).toEqual(typeof {}, 'points[0].xaxis');
992-
expect(typeof pt.yaxis).toEqual(typeof {}, 'points[0].yaxis');
993-
994-
expect(evt.clientX).toEqual(pointPos[0], 'event.clientX');
995-
expect(evt.clientY).toEqual(pointPos[1], 'event.clientY');
996-
});
997-
});
998-
999-
describe('modified click events', function() {
1000-
var clickOpts = {
1001-
altKey: true,
1002-
ctrlKey: true,
1003-
metaKey: true,
1004-
shiftKey: true
1005-
},
1006-
futureData;
1007-
1008-
beforeEach(function(done) {
1009-
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(done);
1010-
1011-
gd.on('plotly_click', function(data) {
1012-
futureData = data;
1013-
});
1014-
});
1015-
1016-
it('should not be trigged when not on data points', function() {
1017-
click(blankPos[0], blankPos[1], clickOpts);
1018-
expect(futureData).toBe(undefined);
1019-
});
1020-
1021-
it('should contain the correct fields', function() {
1022-
click(pointPos[0], pointPos[1], clickOpts);
1023-
1024-
var pt = futureData.points[0],
1025-
evt = futureData.event;
1026-
1027-
expect(Object.keys(pt)).toEqual([
1028-
'data', 'fullData', 'curveNumber', 'pointNumber', 'x', 'y',
1029-
'xaxis', 'yaxis'
1030-
]);
1031-
1032-
expect(pt.curveNumber).toEqual(0, 'points[0].curveNumber');
1033-
expect(typeof pt.data).toEqual(typeof {}, 'points[0].data');
1034-
expect(typeof pt.fullData).toEqual(typeof {}, 'points[0].fullData');
1035-
expect(pt.pointNumber).toEqual(0, 'points[0].pointNumber');
1036-
expect(pt.x).toEqual(undefined, 'points[0].x');
1037-
expect(pt.y).toEqual(undefined, 'points[0].y');
1038-
expect(typeof pt.xaxis).toEqual(typeof {}, 'points[0].xaxis');
1039-
expect(typeof pt.yaxis).toEqual(typeof {}, 'points[0].yaxis');
1040-
1041-
expect(evt.clientX).toEqual(pointPos[0], 'event.clientX');
1042-
expect(evt.clientY).toEqual(pointPos[1], 'event.clientY');
1043-
Object.getOwnPropertyNames(clickOpts).forEach(function(opt) {
1044-
expect(evt[opt]).toEqual(clickOpts[opt], 'event.' + opt);
1045-
});
1046-
});
1047-
});
1048-
1049-
describe('hover events', function() {
1050-
var futureData;
1051-
1052-
beforeEach(function(done) {
1053-
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(done);
1054-
1055-
gd.on('plotly_hover', function(data) {
1056-
futureData = data;
1057-
});
1058-
});
1059-
1060-
it('should contain the correct fields', function() {
1061-
mouseEvent('mousemove', blankPos[0], blankPos[1]);
1062-
mouseEvent('mousemove', pointPos[0], pointPos[1]);
1063-
1064-
var pt = futureData.points[0],
1065-
evt = futureData.event,
1066-
xaxes0 = futureData.xaxes[0],
1067-
xvals0 = futureData.xvals[0],
1068-
yaxes0 = futureData.yaxes[0],
1069-
yvals0 = futureData.yvals[0];
1070-
1071-
expect(Object.keys(pt)).toEqual([
1072-
'data', 'fullData', 'curveNumber', 'pointNumber', 'x', 'y',
1073-
'xaxis', 'yaxis'
1074-
]);
1075-
1076-
expect(pt.curveNumber).toEqual(0, 'points[0].curveNumber');
1077-
expect(typeof pt.data).toEqual(typeof {}, 'points[0].data');
1078-
expect(typeof pt.fullData).toEqual(typeof {}, 'points[0].fullData');
1079-
expect(pt.pointNumber).toEqual(0, 'points[0].pointNumber');
1080-
expect(pt.x).toEqual(undefined, 'points[0].x');
1081-
expect(pt.y).toEqual(undefined, 'points[0].y');
1082-
expect(typeof pt.xaxis).toEqual(typeof {}, 'points[0].xaxis');
1083-
expect(typeof pt.yaxis).toEqual(typeof {}, 'points[0].yaxis');
1084-
1085-
expect(xaxes0).toEqual(pt.xaxis, 'xaxes[0]');
1086-
expect(xvals0).toEqual(-0.0016654247744483342, 'xaxes[0]');
1087-
expect(yaxes0).toEqual(pt.yaxis, 'yaxes[0]');
1088-
expect(yvals0).toEqual(0.5013, 'xaxes[0]');
1089-
1090-
expect(evt.clientX).toEqual(pointPos[0], 'event.clientX');
1091-
expect(evt.clientY).toEqual(pointPos[1], 'event.clientY');
1092-
});
1093-
});
1094-
1095-
describe('unhover events', function() {
1096-
var futureData;
1097-
1098-
beforeEach(function(done) {
1099-
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(done);
1100-
1101-
gd.on('plotly_unhover', function(data) {
1102-
futureData = data;
1103-
});
1104-
});
1105-
1106-
it('should contain the correct fields', function() {
1107-
mouseEvent('mousemove', blankPos[0], blankPos[1]);
1108-
mouseEvent('mousemove', pointPos[0], pointPos[1]);
1109-
mouseEvent('mouseout', pointPos[0], pointPos[1]);
1110-
1111-
var pt = futureData.points[0],
1112-
evt = futureData.event;
1113-
1114-
expect(Object.keys(pt)).toEqual([
1115-
'data', 'fullData', 'curveNumber', 'pointNumber', 'x', 'y',
1116-
'xaxis', 'yaxis'
1117-
]);
1118-
1119-
expect(pt.curveNumber).toEqual(0, 'points[0].curveNumber');
1120-
expect(typeof pt.data).toEqual(typeof {}, 'points[0].data');
1121-
expect(typeof pt.fullData).toEqual(typeof {}, 'points[0].fullData');
1122-
expect(pt.pointNumber).toEqual(0, 'points[0].pointNumber');
1123-
expect(pt.x).toEqual(undefined, 'points[0].x');
1124-
expect(pt.y).toEqual(undefined, 'points[0].y');
1125-
expect(typeof pt.xaxis).toEqual(typeof {}, 'points[0].xaxis');
1126-
expect(typeof pt.yaxis).toEqual(typeof {}, 'points[0].yaxis');
1127-
1128-
expect(evt.clientX).toEqual(pointPos[0], 'event.clientX');
1129-
expect(evt.clientY).toEqual(pointPos[1], 'event.clientY');
1130-
});
1131-
});
1132-
});
1133-
1134-
1135921
describe('dragbox', function() {
1136922

1137923
afterEach(destroyGraphDiv);

0 commit comments

Comments
 (0)