8000 ArrayOk hoverinfo fixups by etpinard · Pull Request #2055 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

ArrayOk hoverinfo fixups #2055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
replace hover-label test boiler-plate with assertHoverLabelContent
  • Loading branch information
etpinard committed Oct 3, 2017
commit 90e2de132bfddbc8d089df79a111b92c2bb2c8a7
34 changes: 11 additions & 23 deletions test/jasmine/tests/gl2d_click_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var fail = require('../assets/fail_test.js');
var assertHoverLabelStyle = require('../assets/custom_assertions').assertHoverLabelStyle;

var customAssertions = require('../assets/custom_assertions');
var assertHoverLabelStyle = customAssertions.assertHoverLabelStyle;
var assertHoverLabelContent = customAssertions.assertHoverLabelContent;

// cartesian click events events use the hover data
// from the mousemove events and then simulate
Expand Down Expand Up @@ -131,25 +134,6 @@ describe('Test hover and click interactions', function() {
expect(String(pt.pointNumber)).toBe(String(expected.pointNumber), msg + ' - point number');
}

function assertHoveLabelContent(expected) {
var label = expected.label;

if(label === undefined) return;

var g = d3.select('.hovertext');

if(label === null) {
expect(g.size()).toBe(0);
} else {
var lines = g.selectAll('text.nums');

expect(lines.size()).toBe(label.length);
lines.each(function(_, i) {
expect(d3.select(this).text()).toEqual(label[i]);
});
}
}

// returns basic hover/click/unhover runner for one xy position
function makeRunner(pos, expected, opts) {
opts = opts || {};
Expand All @@ -166,12 +150,16 @@ describe('Test hover and click interactions', function() {
.then(_hover)
.then(function(eventData) {
assertEventData(eventData, expected);

var g = d3.select('g.hovertext');
if(g.node() === null) {
expect(expected.noHoverLabel).toBe(true);
} else {
assertHoverLabelStyle(g, expected, opts.msg);
}
if(expected.label) {
assertHoverLabelContent([expected.label, null]);
}
else assertHoverLabelStyle(g, expected, opts.msg);
assertHoveLabelContent(expected);
})
.then(_click)
.then(function(eventData) {
Expand Down Expand Up @@ -211,7 +199,7 @@ describe('Test hover and click interactions', function() {
var run = makeRunner([634, 321], {
x: 15.772,
y: 0.387,
label: ['0.387'],
label: ['0.387', null],
curveNumber: 0,
pointNumber: 33,
bgcolor: 'rgb(0, 0, 255)',
Expand Down
19 changes: 7 additions & 12 deletions test/jasmine/tests/gl_plot_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ var fail = require('../assets/fail_test');
var mouseEvent = require('../assets/mouse_event');
var selectButton = require('../assets/modebar_button');
var delay = require('../assets/delay');
var assertHoverLabelStyle = require('../assets/custom_assertions').assertHoverLabelStyle;

var customAssertions = require('../assets/custom_assertions');
var assertHoverLabelStyle = customAssertions.assertHoverLabelStyle;
var assertHoverLabelContent = customAssertions.assertHoverLabelContent;

function countCanvases() {
return d3.selectAll('canvas').size();
Expand All @@ -33,17 +36,9 @@ describe('Test gl3d plots', function() {
var mock3 = require('@mocks/gl3d_autocolorscale');

function assertHoverText(xLabel, yLabel, zLabel, textLabel) {
var node = d3.selectAll('g.hovertext');
expect(node.size()).toEqual(1, 'hover text group');

var tspan = d3.selectAll('g.hovertext').selectAll('tspan')[0];
expect(tspan[0].innerHTML).toEqual(xLabel, 'x val');
expect(tspan[1].innerHTML).toEqual(yLabel, 'y val');
expect(tspan[2].innerHTML).toEqual(zLabel, 'z val');

if(textLabel) {
expect(tspan[3].innerHTML).toEqual(textLabel, 'text label');
}
var content = [xLabel, yLabel, zLabel];
if(textLabel) content.push(textLabel);
assertHoverLabelContent([[content, null], null]);
}

function assertEventData(x, y, z, curveNumber, pointNumber, extra) {
Expand Down
Loading
0