Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
icarito committed Jun 14, 2016
1 parent 8092ec1 commit 0073850
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion spec/javascripts/set_spec.js
Expand Up @@ -100,8 +100,21 @@ describe("Set", function() {
it("should highlight table row when hovering over graph line ", function() {
*/

// Manual event triggering uses selection.dispatch in d3 4.0:
// https://github.com/d3/d3-selection#selection_dispatch
// in the meantime, we create a one-off trigger():
// https://github.com/d3/d3/issues/100
d3.selection.prototype.trigger = function( event ) {
var e = document.createEvent('Event');
e.initEvent( event, true, true);
this.each( function( d ) {
this.dispatchEvent( e );
});
return this;
}

// this syntax is to trigger an SVG mouseover using D3:
d3.select('g.nv-scatterWrap g#spectrum-hover-1')[0][0].dispatchEvent(new MouseEvent('mouseover'));
d3.select('g.nv-scatterWrap g#spectrum-hover-1').trigger('mouseover');

expect($('tr.spectrum-1').hasClass('highlight')).toBe(true);
expect($('tr.spectrum-2').hasClass('highlight')).toBe(false);
Expand Down

0 comments on commit 0073850

Please sign in to comment.