Skip to content

Commit 30ca2ec

Browse files
author
Jon M. Mease
committed
Add tests for clicking on category and path with hovermode 'color'
1 parent 66f21fe commit 30ca2ec

File tree

1 file changed

+100
-4
lines changed

1 file changed

+100
-4
lines changed

test/jasmine/tests/parcats_test.js

Lines changed: 100 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,9 +1330,109 @@ describe('Click events', function() {
13301330
});
13311331
});
13321332

1333+
describe('Click events with hovermode color', function() {
1334+
1335+
// Variable declarations
1336+
// ---------------------
1337+
// ### Trace level ###
1338+
var gd,
1339+
mock;
1340+
1341+
// Fixtures
1342+
// --------
1343+
beforeEach(function() {
1344+
gd = createGraphDiv();
1345+
mock = Lib.extendDeep({}, require('@mocks/parcats_hovermode_color.json'));
1346+
});
1347+
1348+
afterEach(destroyGraphDiv);
1349+
1350+
it('should fire on category click', function(done) {
1351+
1352+
var clickData;
1353+
Plotly.newPlot(gd, mock)
1354+
.then(function() {
1355+
/** @type {ParcatsViewModel} */
1356+
var parcatsViewModel = d3.select('g.trace.parcats').datum();
1357+
1358+
gd.on('plotly_click', function(data) {
1359+
clickData = data;
1360+
});
1361+
1362+
// Click on the top of the lowest category in the middle dimension (category "C")
1363+
var dimStartX = parcatsViewModel.dimensions[1].x;
1364+
var mouseY = parcatsViewModel.y + parcatsViewModel.dimensions[1].categories[2].y + 10,
1365+
mouseX = parcatsViewModel.x + dimStartX + dimWidth / 2;
1366+
1367+
// Position mouse for start of drag
1368+
// --------------------------------
1369+
click(mouseX, mouseY);
1370+
})
1371+
.then(delay(CALLBACK_DELAY))
1372+
.then(function() {
1373+
// Check that click callback was called
1374+
expect(clickData).toBeDefined();
1375+
1376+
// Check that the right points were reported
1377+
var pts = clickData.points.sort(function(a, b) {
1378+
return a.pointNumber - b.pointNumber;
1379+
});
1380+
1381+
// Check points
1382+
expect(pts).toEqual([
1383+
{curveNumber: 0, pointNumber: 5}]);
1384+
})
1385+
.catch(failTest)
1386+
.then(done);
1387+
});
1388+
1389+
1390+
it('should fire on path click', function(done) {
1391+
1392+
var clickData;
1393+
1394+
Plotly.newPlot(gd, mock)
1395+
.then(function() {
1396+
/** @type {ParcatsViewModel} */
1397+
var parcatsViewModel = d3.select('g.trace.parcats').datum();
1398+
1399+
gd.on('plotly_click', function(data) {
1400+
clickData = data;
1401+
});
1402+
1403+
// Click on the top path to the right of the lowest category in the middle dimension (category "C")
1404+
var dimStartX = parcatsViewModel.dimensions[1].x;
1405+
var mouseY = parcatsViewModel.y + parcatsViewModel.dimensions[1].categories[2].y + 10,
1406+
mouseX = parcatsViewModel.x + dimStartX + dimWidth + 10;
1407+
1408+
// Position mouse for start of drag
1409+
// --------------------------------
1410+
click(mouseX, mouseY);
1411+
})
1412+
.then(delay(CALLBACK_DELAY))
1413+
.then(function() {
1414+
// Check that click callback was called
1415+
expect(clickData).toBeDefined();
1416+
1417+
// Check that the right points were reported
1418+
var pts = clickData.points.sort(function(a, b) {
1419+
return a.pointNumber - b.pointNumber;
1420+
});
1421+
1422+
// Check points
1423+
expect(pts).toEqual([
1424+
{curveNumber: 0, pointNumber: 5}]);
1425+
})
1426+
.catch(failTest)
1427+
.then(done);
1428+
});
1429+
});
1430+
13331431
// To Test
13341432
// -------
1433+
13351434
// ### Hovering
1435+
// - Hover down to top middle category, and top path.
13361436
// - [ ] Path hover label
13371437
// - [ ] Category hover label for 'category', 'color', and 'dimension', `hovermode`
13381438
// - [ ] No category hover label for 'none', 'skip' `hovermode
@@ -1349,7 +1449,3 @@ describe('Click events', function() {
13491449
//
13501450
//
13511451
// ### Test Font styles ###
1352-
1353-
// ### Test visible
1354-
1355-
// ### Test colorscale with numeric colors

0 commit comments

Comments
 (0)