Skip to content

Commit 98c18f8

Browse files
committed
clean up sankey test
push _hover into outer scope. use d3 size() instead of manually checking objects length.
1 parent 45f06c4 commit 98c18f8

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

test/jasmine/tests/sankey_test.js

+7-19
Original file line numberDiff line numberDiff line change
@@ -388,16 +388,16 @@ describe('sankey tests', function() {
388388
describe('Test hover/click interactions:', function() {
389389
afterEach(destroyGraphDiv);
390390

391+
function _hover(px, py) {
392+
mouseEvent('mousemove', px, py);
393+
mouseEvent('mouseover', px, py);
394+
Lib.clearThrottle();
395+
}
396+
391397
it('should show the correct hover labels', function(done) {
392398
var gd = createGraphDiv();
393399
var mockCopy = Lib.extendDeep({}, mock);
394400

395-
function _hover(px, py) {
396-
mouseEvent('mousemove', px, py);
397-
mouseEvent('mouseover', px, py);
398-
Lib.clearThrottle();
399-
}
400-
401401
Plotly.plot(gd, mockCopy).then(function() {
402402
_hover(404, 302);
403403

@@ -464,12 +464,6 @@ describe('sankey tests', function() {
464464
var mockCopy = Lib.extendDeep({}, mock);
465465
delete mockCopy.data[0].link.label;
466466

467-
function _hover(px, py) {
468-
mouseEvent('mousemove', px, py);
469-
mouseEvent('mouseover', px, py);
470-
Lib.clearThrottle();
471-
}
472-
473467
Plotly.plot(gd, mockCopy)
474468
.then(function() {
475469
_hover(450, 300);
@@ -487,12 +481,6 @@ describe('sankey tests', function() {
487481
var gd = createGraphDiv();
488482
var mockCopy = Lib.extendDeep({}, mock);
489483

490-
function _hover(px, py) {
491-
mouseEvent('mousemove', px, py);
492-
mouseEvent('mouseover', px, py);
493-
Lib.clearThrottle();
494-
}
495-
496484
Plotly.plot(gd, mockCopy).then(function() {
497485
return Plotly.relayout(gd, 'hovermode', false);
498486
})
@@ -645,5 +633,5 @@ function assertLabel(content, style) {
645633

646634
function assertNoLabel() {
647635
var g = d3.selectAll('.hovertext');
648-
expect(g[0].length).toBe(0);
636+
expect(g.size()).toBe(0);
649637
}

0 commit comments

Comments
 (0)