Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Enable unit testing for module Network #3313

Merged
merged 9 commits into from
Aug 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions lib/network/modules/CanvasRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
* * During unit testing, it happens that the window object is reset during execution, causing
* a runtime error due to missing `requestAnimationFrame()`. This needs to be compensated for,
* see `_requestNextFrame()`.
* * Since this is a global object, it may affect other modules besides `Network`! This has not
* caused any problems yet. The method is only used within `Network`.
* * Since this is a global object, it may affect other modules besides `Network`. With normal
* usage, this does not cause any problems. During unit testing, errors may occur. These have
* been compensated for, see comment block in _requestNextFrame().
*
* @private
*/
Expand Down Expand Up @@ -127,6 +128,9 @@ class CanvasRenderer {
// 'requestAnimationFrame()' is not present because it is not defined on the
// mock window object.
//
// As a consequence, unrelated unit tests may appear to fail, even if the problem
// described happens in the current unit test.
//
// This is not something that will happen in normal operation, but we still need
// to take it into account.
if (window === undefined) return;
Expand Down
2 changes: 2 additions & 0 deletions test/Network.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ describe('Network', function () {
},
clusterNodeProperties: {id:"c1", label:'c1'}
}

network.cluster(clusterOptionsByData);
numNodes += 1; // new cluster node
assertNumNodes(network, numNodes, numNodes - 3); // 3 clustered nodes
Expand Down Expand Up @@ -273,6 +274,7 @@ describe('on node.js', function () {


describe('runs example ', function () {

function loadExample(path, noPhysics) {
include(path, this);
var container = document.getElementById('mynetwork');
Expand Down