Browse Source

Network: fit() should not change the passed options (#3566)

Fixes #3543.

None of the options passed in any of the API calls should change the options. This has been registered with issue #3548.
mbroad/code-climate-coverage-develop
wimrijnders 7 years ago
committed by Yotam Berkowitz
parent
commit
c56fa199b5
2 changed files with 19 additions and 1 deletions
  1. +2
    -1
      lib/network/modules/View.js
  2. +17
    -0
      test/Network.test.js

+ 2
- 1
lib/network/modules/View.js View File

@ -49,6 +49,7 @@ class View {
fit(options = {nodes:[]}, initialZoom = false) {
let range;
let zoomLevel;
options = Object.assign({}, options);
if (options.nodes === undefined || options.nodes.length === 0) {
options.nodes = this.body.nodeIndices;
}
@ -299,4 +300,4 @@ class View {
}
export default View;
export default View;

+ 17
- 0
test/Network.test.js View File

@ -352,6 +352,23 @@ describe('Network', function () {
});
/**
* This is a fix on one issue (#3543), but in fact **all* options for all API calls should
* remain unchanged.
* TODO: extend test for all API calls with options, see #3548
*/
it('does not change the options object passed to fit()', function() {
var [network, data, numNodes, numEdges] = createSampleNetwork({});
var options = {};
network.fit(options);
// options should still be empty
for (var prop in options) {
assert(!options.hasOwnProperty(prop), 'No properties should be present in options, detected property: ' + prop);
}
});
describe('Node', function () {
it('has known font options', function () {

Loading…
Cancel
Save