aboutsummaryrefslogtreecommitdiffstats
path: root/gui-clamp/ui-react/src/components/loop_viewer/svg
diff options
context:
space:
mode:
Diffstat (limited to 'gui-clamp/ui-react/src/components/loop_viewer/svg')
-rw-r--r--gui-clamp/ui-react/src/components/loop_viewer/svg/SvgGenerator.js3
-rw-r--r--gui-clamp/ui-react/src/components/loop_viewer/svg/SvgGenerator.test.js34
2 files changed, 34 insertions, 3 deletions
diff --git a/gui-clamp/ui-react/src/components/loop_viewer/svg/SvgGenerator.js b/gui-clamp/ui-react/src/components/loop_viewer/svg/SvgGenerator.js
index 2692aef..2eba102 100644
--- a/gui-clamp/ui-react/src/components/loop_viewer/svg/SvgGenerator.js
+++ b/gui-clamp/ui-react/src/components/loop_viewer/svg/SvgGenerator.js
@@ -73,7 +73,6 @@ class SvgGenerator extends React.Component {
}
handleSvgClick(event) {
- console.debug("svg click event received");
if (this.state.clickable) {
var elementName = event.target.parentNode.getAttribute('policyId');
console.info("SVG element clicked", elementName);
@@ -148,7 +147,6 @@ class SvgGenerator extends React.Component {
xPos += (this.boxWidth + this.boxSpace);
allElements.push(this.createOneArrow(xPos - this.boxSpace));
- //createOneBox(xPos, policyId, loopElementModelId , name, title, policyType)
for (var loopElement of this.state.loopCache.getAllLoopElementModels()) {
allElements.push(this.createOneBox(xPos,
@@ -218,6 +216,7 @@ class SvgGenerator extends React.Component {
}
renderSvg() {
+ console.log('renderSvg called');
if (this.state.loopCache.getLoopName() === undefined) {
return [emptySvg];
}
diff --git a/gui-clamp/ui-react/src/components/loop_viewer/svg/SvgGenerator.test.js b/gui-clamp/ui-react/src/components/loop_viewer/svg/SvgGenerator.test.js
index 13c31d1..b8c32dc 100644
--- a/gui-clamp/ui-react/src/components/loop_viewer/svg/SvgGenerator.test.js
+++ b/gui-clamp/ui-react/src/components/loop_viewer/svg/SvgGenerator.test.js
@@ -21,11 +21,43 @@ import {shallow} from "enzyme";
import toJson from "enzyme-to-json";
import React from "react";
import SvgGenerator from "./SvgGenerator";
+import {Router} from "react-router-dom";
+import {createMemoryHistory} from "history";
+import LoopCache from "../../../api/LoopCache";
+import {act} from "react-dom/test-utils";
+
+const logSpy = jest.spyOn(console, 'log')
+const history = createMemoryHistory();
describe('Verify SvgGenerator', () => {
it("renders correctly", () => {
- const component = shallow(<SvgGenerator />);
+ const component = shallow(<SvgGenerator/>);
expect(toJson(component)).toMatchSnapshot();
});
+
+ it("Test renderSvg called", () => {
+ shallow(
+ <Router history={history}>
+ <SvgGenerator loopCache={new LoopCache({})} clickable={ true } generatedFrom='INSTANCE' isBusyLoading={false}/>
+ </Router>
+ );
+
+ act(async () => {
+ expect(logSpy).toHaveBeenCalledWith('renderSvg called');
+ });
+ });
+
+ it("Test svg click event received", () => {
+ const component = shallow(
+ <Router history={history}>
+ <SvgGenerator loopCache={new LoopCache({})} clickable={ true } generatedFrom='INSTANCE' isBusyLoading={false}/>
+ </Router>
+ );
+
+ act(async () => {
+ component.find('withRouter(SvgGenerator)').simulate('click');
+ expect(logSpy).toHaveBeenCalledWith('svg click event received');
+ });
+ });
}); \ No newline at end of file