@@ -1137,16 +1137,10 @@ describe('sankey tests', function() {
11371137 afterEach ( destroyGraphDiv ) ;
11381138
11391139 function _makeWrapper ( eventType , mouseFn ) {
1140- function _pos ( elType ) {
1141- // index 4 = 'Solid' node, pointNumber 61 = the link asserted in the hover/click tests below.
1142- // Using DOM-based lookup rather than hardcoded pixel coords so the tests are robust
1143- // against small layout differences across environments.
1144- const el = elType === 'node'
1145- ? d3SelectAll ( '.sankey-node' ) . filter ( ( d ) => d . index === 4 ) . select ( '.node-rect' ) . node ( )
1146- : d3SelectAll ( '.sankey-link' ) . filter ( ( d ) => d . pointNumber === 61 ) . select ( 'path' ) . node ( ) ;
1147- var bbox = el . getBoundingClientRect ( ) ;
1148- return [ bbox . left + bbox . width / 2 , bbox . top + bbox . height / 2 ] ;
1149- }
1140+ var posByElementType = {
1141+ node : [ 410 , 300 ] ,
1142+ link : [ 450 , 300 ]
1143+ } ;
11501144
11511145 return function ( elType ) {
11521146 return new Promise ( function ( resolve , reject ) {
@@ -1155,7 +1149,7 @@ describe('sankey tests', function() {
11551149 resolve ( d ) ;
11561150 } ) ;
11571151
1158- mouseFn ( _pos ( elType ) ) ;
1152+ mouseFn ( posByElementType [ elType ] ) ;
11591153 setTimeout ( function ( ) {
11601154 reject ( eventType + ' did not get called!' ) ;
11611155 } , 100 ) ;
@@ -1466,8 +1460,8 @@ describe('sankey tests', function() {
14661460 nodes = document . getElementsByClassName ( 'sankey-node' ) ;
14671461 node = Array . prototype . slice . call ( nodes ) . find ( function ( n ) { return n . textContent === '0' ; } ) ;
14681462 var newPosition = getNodeCoords ( node ) ;
1469- expect ( newPosition . x ) . toBeCloseTo ( positionAfterDrag [ 0 ] , 2 , 'final x position is off' ) ;
1470- expect ( newPosition . y ) . toBeCloseTo ( positionAfterDrag [ 1 ] , 2 , 'final y position is off' ) ;
1463+ expect ( newPosition . x ) . toBeCloseTo ( positionAfterDrag [ 0 ] , - 1 , 'final x position is off' ) ;
1464+ expect ( newPosition . y ) . toBeCloseTo ( positionAfterDrag [ 1 ] , - 1 , 'final y position is off' ) ;
14711465
14721466 // Change color of nodes
14731467 var mockCopy = Lib . extendDeep ( { } , mockCircularFreeform ) ;
@@ -1491,8 +1485,8 @@ describe('sankey tests', function() {
14911485 pos = positionBeforeDrag ;
14921486 msg = 'should go back to its default because uirevision changed' ;
14931487 }
1494- expect ( newPosition . x ) . toBeCloseTo ( pos [ 0 ] , 2 , 'x position ' + msg ) ;
1495- expect ( newPosition . y ) . toBeCloseTo ( pos [ 1 ] , 2 , 'y position ' + msg ) ;
1488+ expect ( newPosition . x ) . toBeCloseTo ( pos [ 0 ] , - 1 , 'x position ' + msg ) ;
1489+ expect ( newPosition . y ) . toBeCloseTo ( pos [ 1 ] , - 1 , 'y position ' + msg ) ;
14961490 } )
14971491 . then ( done , done . fail ) ;
14981492 } ) ;
0 commit comments