Skip to content
Open
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
3 changes: 3 additions & 0 deletions __tests__/utilities/graph-util.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import * as React from 'react';
import ReactDOM from 'react-dom';
import { shallow } from 'enzyme';
import GraphView from '../../src/components/graph-view';

Expand Down Expand Up @@ -128,6 +129,7 @@ describe('GraphUtils class', () => {

describe('removeElementFromDom method', () => {
it('removes an element using an id', () => {
ReactDOM.unmountComponentAtNode = jest.fn();
const fakeElement = {
parentNode: {
removeChild: jest.fn(),
Expand All @@ -137,6 +139,7 @@ describe('GraphUtils class', () => {
jest.spyOn(document, 'querySelector').mockReturnValue(fakeElement);
const result = GraphUtils.removeElementFromDom('fake');

expect(ReactDOM.unmountComponentAtNode).toHaveBeenCalledWith(fakeElement);
expect(fakeElement.parentNode.removeChild).toHaveBeenCalledWith(
fakeElement
);
Expand Down
2 changes: 2 additions & 0 deletions src/utilities/graph-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { type IEdge } from '../components/edge';
import { type INode } from '../components/node';
import { type IPoint } from '../components/graph-view-props';
import fastDeepEqual from 'fast-deep-equal';
import ReactDOM from 'react-dom';

export type INodeMapNode = {
node: INode,
Expand Down Expand Up @@ -106,6 +107,7 @@ class GraphUtils {
const container = searchElement.querySelector(`[id='${id}']`);

if (container && container.parentNode) {
ReactDOM.unmountComponentAtNode(container);
container.parentNode.removeChild(container);

return true;
Expand Down