(move)
| 1333 | }); |
| 1334 | |
| 1335 | function testDragNode(move) { |
| 1336 | return function() { |
| 1337 | var position; |
| 1338 | var nodes; |
| 1339 | var node; |
| 1340 | |
| 1341 | return Promise.resolve() |
| 1342 | .then(function() { |
| 1343 | nodes = document.getElementsByClassName('sankey-node'); |
| 1344 | node = nodes.item(nodeId); |
| 1345 | position = getNodeCoords(node); |
| 1346 | var timeDelay = (arrangement === 'snap') ? 2000 : 0; // Wait for force simulation to finish |
| 1347 | return drag({node: node, dpos: move, nsteps: 10, timeDelay: timeDelay}); |
| 1348 | }) |
| 1349 | .then(function() { |
| 1350 | nodes = document.getElementsByClassName('sankey-node'); |
| 1351 | node = nodes.item(nodes.length - 1); // Dragged node is now the last one |
| 1352 | var newPosition = getNodeCoords(node); |
| 1353 | if(arrangement === 'freeform') { |
| 1354 | expect(newPosition.x).toBeCloseTo(position.x + move[0], 0, 'final x position is off'); |
| 1355 | } |
| 1356 | expect(newPosition.y).toBeCloseTo(position.y + move[1], 2, 'final y position is off'); |
| 1357 | return Promise.resolve(true); |
| 1358 | }); |
| 1359 | }; |
| 1360 | } |
| 1361 | |
| 1362 | it('should change the position of a node on drag', function(done) { |
| 1363 | mockCopy.data[0].arrangement = arrangement; |
no test coverage detected
searching dependent graphs…