Skip to content

Commit 5cdf009

Browse files
committed
events: move pie tests to hover_pie_test.js
1 parent 00baba0 commit 5cdf009

File tree

2 files changed

+205
-188
lines changed

2 files changed

+205
-188
lines changed

test/jasmine/tests/click_test.js

Lines changed: 0 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -928,192 +928,6 @@ describe('Test click interactions:', function() {
928928
});
929929

930930

931-
describe('Test click interactions on a pie plot:', function() {
932-
var mock = require('@mocks/pie_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('g.slicetext');
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-
expect(futureData.points.length).toEqual(1);
977-
978-
var pt = futureData.points[0];
979-
expect(Object.keys(pt)).toEqual([
980-
'v', 'label', 'color', 'i', 'hidden', 'vTotal', 'text', 't',
981-
'trace', 'r', 'cx', 'cy', 'px1', 'pxmid', 'midangle', 'px0',
982-
'largeArc', 'cxFinal', 'cyFinal'
983-
]);
984-
expect(typeof pt.color).toEqual(typeof '#1f77b4', 'points[0].color');
985-
expect(pt.cx).toEqual(200, 'points[0].cx');
986-
expect(pt.cxFinal).toEqual(200, 'points[0].cxFinal');
987-
expect(pt.cy).toEqual(160, 'points[0].cy');
988-
expect(pt.cyFinal).toEqual(160, 'points[0].cyFinal');
989-
expect(pt.hidden).toEqual(false, 'points[0].hidden');
990-
expect(pt.i).toEqual(4, 'points[0].i');
991-
expect(pt.label).toEqual('4', 'points[0].label');
992-
expect(pt.largeArc).toEqual(0, 'points[0].largeArc');
993-
expect(pt.midangle).toEqual(1.0471975511965976, 'points[0].midangle');
994-
expect(pt.px0).toEqual([0, -60], 'points[0].px0');
995-
expect(pt.px1).toEqual([51.96152422706632, 29.999999999999986], 'points[0].px1');
996-
expect(pt.pxmid).toEqual([51.96152422706631, -30.000000000000007], 'points[0].pxmid');
997-
expect(pt.r).toEqual(60, 'points[0].r');
998-
expect(typeof pt.t).toEqual(typeof {}, 'points[0].t');
999-
expect(pt.text).toEqual('33.3%', 'points[0].text');
1000-
expect(typeof pt.trace).toEqual(typeof {}, 'points[0].trace');
1001-
expect(pt.v).toEqual(5, 'points[0].v');
1002-
expect(pt.vTotal).toEqual(15, 'points[0].vTotal');
1003-
1004-
var evt = futureData.event;
1005-
expect(evt.clientX).toEqual(pointPos[0], 'event.clientX');
1006-
expect(evt.clientY).toEqual(pointPos[1], 'event.clientY');
1007-
});
1008-
});
1009-
1010-
describe('modified click events', function() {
1011-
var clickOpts = {
1012-
altKey: true,
1013-
ctrlKey: true,
1014-
metaKey: true,
1015-
shiftKey: true
1016-
},
1017-
futureData;
1018-
1019-
beforeEach(function(done) {
1020-
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(done);
1021-
1022-
gd.on('plotly_click', function(data) {
1023-
futureData = data;
1024-
});
1025-
});
1026-
1027-
it('should not be trigged when not on data points', function() {
1028-
click(blankPos[0], blankPos[1], clickOpts);
1029-
expect(futureData).toBe(undefined);
1030-
});
1031-
1032-
it('should contain the correct fields', function() {
1033-
click(pointPos[0], pointPos[1], clickOpts);
1034-
expect(futureData.points.length).toEqual(1);
1035-
1036-
var pt = futureData.points[0];
1037-
expect(Object.keys(pt)).toEqual([
1038-
'v', 'label', 'color', 'i', 'hidden', 'vTotal', 'text', 't',
1039-
'trace', 'r', 'cx', 'cy', 'px1', 'pxmid', 'midangle', 'px0',
1040-
'largeArc', 'cxFinal', 'cyFinal'
1041-
]);
1042-
expect(typeof pt.color).toEqual(typeof '#1f77b4', 'points[0].color');
1043-
expect(pt.cx).toEqual(200, 'points[0].cx');
1044-
expect(pt.cxFinal).toEqual(200, 'points[0].cxFinal');
1045-
expect(pt.cy).toEqual(160, 'points[0].cy');
1046-
expect(pt.cyFinal).toEqual(160, 'points[0].cyFinal');
1047-
expect(pt.hidden).toEqual(false, 'points[0].hidden');
1048-
expect(pt.i).toEqual(4, 'points[0].i');
1049-
expect(pt.label).toEqual('4', 'points[0].label');
1050-
expect(pt.largeArc).toEqual(0, 'points[0].largeArc');
1051-
expect(pt.midangle).toEqual(1.0471975511965976, 'points[0].midangle');
1052-
expect(pt.px0).toEqual([0, -60], 'points[0].px0');
1053-
expect(pt.px1).toEqual([51.96152422706632, 29.999999999999986], 'points[0].px1');
1054-
expect(pt.pxmid).toEqual([51.96152422706631, -30.000000000000007], 'points[0].pxmid');
1055-
expect(pt.r).toEqual(60, 'points[0].r');
1056-
expect(typeof pt.t).toEqual(typeof {}, 'points[0].t');
1057-
expect(pt.text).toEqual('33.3%', 'points[0].text');
1058-
expect(typeof pt.trace).toEqual(typeof {}, 'points[0].trace');
1059-
expect(pt.v).toEqual(5, 'points[0].v');
1060-
expect(pt.vTotal).toEqual(15, 'points[0].vTotal');
1061-
1062-
var evt = futureData.event;
1063-
expect(evt.clientX).toEqual(pointPos[0], 'event.clientX');
1064-
expect(evt.clientY).toEqual(pointPos[1], 'event.clientY');
1065-
Object.getOwnPropertyNames(clickOpts).forEach(function(opt) {
1066-
expect(evt[opt]).toEqual(clickOpts[opt], 'event.' + opt);
1067-
});
1068-
});
1069-
});
1070-
1071-
describe('hover events', function() {
1072-
var futureData;
1073-
1074-
beforeEach(function(done) {
1075-
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(done);
1076-
1077-
gd.on('plotly_hover', function(data) {
1078-
futureData = data;
1079-
});
1080-
});
1081-
1082-
it('should contain the correct fields', function() {
1083-
mouseEvent('mouseover', pointPos[0], pointPos[1]);
1084-
1085-
var point0 = futureData.points[0],
1086-
evt = futureData.event;
1087-
expect(point0).toEqual(evt, 'points');
1088-
expect(evt.clientX).toEqual(pointPos[0], 'event.clientX');
1089-
expect(evt.clientY).toEqual(pointPos[1], 'event.clientY');
1090-
});
1091-
});
1092-
1093-
describe('unhover events', function() {
1094-
var futureData;
1095-
1096-
beforeEach(function(done) {
1097-
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(done);
1098-
1099-
gd.on('plotly_unhover', function(data) {
1100-
futureData = data;
1101-
});
1102-
});
1103-
1104-
it('should contain the correct fields', function() {
1105-
mouseEvent('mouseout', pointPos[0], pointPos[1]);
1106-
1107-
var point0 = futureData.points[0],
1108-
evt = futureData.event;
1109-
expect(point0).toEqual(evt, 'points');
1110-
expect(evt.clientX).toEqual(pointPos[0], 'event.clientX');
1111-
expect(evt.clientY).toEqual(pointPos[1], 'event.clientY');
1112-
});
1113-
});
1114-
});
1115-
1116-
1117931
describe('Test click interactions on a ternary plot:', function() {
1118932
var mock = require('@mocks/ternary_simple.json');
1119933

0 commit comments

Comments
 (0)