diff --git a/src/components/graph/graph.helper.js b/src/components/graph/graph.helper.js index ffff9cd32..abf9d8dac 100644 --- a/src/components/graph/graph.helper.js +++ b/src/components/graph/graph.helper.js @@ -297,10 +297,6 @@ function buildLinkProps(link, nodes, links, config, linkCallbacks, highlightedNo d, source, target, - x1, - y1, - x2, - y2, strokeWidth, stroke, mouseCursor: config.link.mouseCursor, @@ -434,7 +430,7 @@ function checkForGraphElementsChanges(nextProps, currentState) { function checkForGraphConfigChanges(nextProps, currentState) { const newConfig = nextProps.config || {}; const configUpdated = - newConfig && !utils.isObjectEmpty(newConfig) && !utils.isDeepEqual(newConfig, currentState.config); + newConfig && !utils.isEmptyObject(newConfig) && !utils.isDeepEqual(newConfig, currentState.config); const d3ConfigUpdated = newConfig && newConfig.d3 && !utils.isDeepEqual(newConfig.d3, currentState.config.d3); return { configUpdated, d3ConfigUpdated }; diff --git a/src/components/link/Link.jsx b/src/components/link/Link.jsx index af5b467a0..01a8ef145 100644 --- a/src/components/link/Link.jsx +++ b/src/components/link/Link.jsx @@ -23,10 +23,6 @@ import React from 'react'; * d="M1..." * source='idSourceNode' * target='idTargetNode' - * x1=22 - * y1=22 - * x2=22 - * y2=22 * markerId='marker-small' * strokeWidth=1.5 * stroke='green' diff --git a/src/utils.js b/src/utils.js index 62a9da31b..c8638ba11 100644 --- a/src/utils.js +++ b/src/utils.js @@ -17,7 +17,7 @@ const MAX_DEPTH = 20; * @memberof utils */ function _isPropertyNestedObject(o, k) { - return o.hasOwnProperty(k) && typeof o[k] === 'object' && o[k] !== null && !isObjectEmpty(o[k]); + return o.hasOwnProperty(k) && typeof o[k] === 'object' && o[k] !== null && !isEmptyObject(o[k]); } /** @@ -35,7 +35,7 @@ function isDeepEqual(o1, o2, _depth = 0) { return true; } - if ((isObjectEmpty(o1) && !isObjectEmpty(o2)) || (!isObjectEmpty(o1) && isObjectEmpty(o2))) { + if ((isEmptyObject(o1) && !isEmptyObject(o2)) || (!isEmptyObject(o1) && isEmptyObject(o2))) { return false; } @@ -52,7 +52,7 @@ function isDeepEqual(o1, o2, _depth = 0) { if (nestedO && _depth < MAX_DEPTH) { diffs.push(isDeepEqual(o1[k], o2[k], _depth + 1)); } else { - const r = (isObjectEmpty(o1[k]) && isObjectEmpty(o2[k])) || (o2.hasOwnProperty(k) && o2[k] === o1[k]); + const r = (isEmptyObject(o1[k]) && isEmptyObject(o2[k])) || (o2.hasOwnProperty(k) && o2[k] === o1[k]); diffs.push(r); @@ -72,7 +72,7 @@ function isDeepEqual(o1, o2, _depth = 0) { * @returns {boolean} true if the given object is n ft and object and is empty. * @memberof utils */ -function isObjectEmpty(o) { +function isEmptyObject(o) { return !!o && typeof o === 'object' && !Object.keys(o).length; } @@ -90,7 +90,7 @@ function merge(o1 = {}, o2 = {}, _depth = 0) { let o = {}; if (Object.keys(o1 || {}).length === 0) { - return o2 && !isObjectEmpty(o2) ? o2 : {}; + return o2 && !isEmptyObject(o2) ? o2 : {}; } for (let k of Object.keys(o1)) { @@ -155,7 +155,7 @@ function throwErr(component, msg) { export default { isDeepEqual, - isObjectEmpty, + isEmptyObject, merge, pick, antiPick, diff --git a/test/component/graph/graph.helper.test.js b/test/component/graph/graph.helper.test.js index 4bbb47d3b..d7fd3ac7b 100644 --- a/test/component/graph/graph.helper.test.js +++ b/test/component/graph/graph.helper.test.js @@ -16,7 +16,7 @@ import { describe('Graph Helper', () => { beforeAll(() => { utils.isDeepEqual = jest.fn(); - utils.isObjectEmpty = jest.fn(); + utils.isEmptyObject = jest.fn(); utils.merge = jest.fn(); utils.throwErr = jest.fn(); jest.spyOn(linkHelper, 'buildLinkPathDefinition'); diff --git a/test/utils.test.js b/test/utils.test.js index a8a417c4d..fa04c84fd 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -45,15 +45,15 @@ describe('Utils', () => { }); }); - describe('#isObjectEmpty', () => { + describe('#isEmptyObject', () => { test('should properly check whether the object is empty or not', () => { - expect(utils.isObjectEmpty({ a: 1, b: {} })).toEqual(false); - expect(utils.isObjectEmpty({ a: 1 })).toEqual(false); - expect(utils.isObjectEmpty(null)).toEqual(false); - expect(utils.isObjectEmpty(undefined)).toEqual(false); - expect(utils.isObjectEmpty(0)).toEqual(false); - expect(utils.isObjectEmpty('test')).toEqual(false); - expect(utils.isObjectEmpty({})).toEqual(true); + expect(utils.isEmptyObject({ a: 1, b: {} })).toEqual(false); + expect(utils.isEmptyObject({ a: 1 })).toEqual(false); + expect(utils.isEmptyObject(null)).toEqual(false); + expect(utils.isEmptyObject(undefined)).toEqual(false); + expect(utils.isEmptyObject(0)).toEqual(false); + expect(utils.isEmptyObject('test')).toEqual(false); + expect(utils.isEmptyObject({})).toEqual(true); }); });