summaryrefslogtreecommitdiffstats
path: root/gui-clamp
diff options
context:
space:
mode:
authorbrunomilitzer <bruno.militzer@est.tech>2022-03-14 11:29:25 +0000
committerbrunomilitzer <bruno.militzer@est.tech>2022-03-14 17:16:31 +0000
commit1e27cabdaf7c89a2c7381c8a46697be007778445 (patch)
tree122ebf8705508f8ffea8594ba81cfe2a4fb6326a /gui-clamp
parent5d87357d69ec81962fd6128a8aa12086b97f199f (diff)
Added more unit tests for overall coverage
Issue-ID: POLICY-3932 Change-Id: I481f5da35047da7a790f02368cc915d5e1a9e04d Signed-off-by: brunomilitzer <bruno.militzer@est.tech>
Diffstat (limited to 'gui-clamp')
-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
-rw-r--r--gui-clamp/ui-react/src/components/menu/MenuBar.js11
-rw-r--r--gui-clamp/ui-react/src/components/menu/MenuBar.test.js7
-rw-r--r--gui-clamp/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap80
5 files changed, 63 insertions, 72 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
diff --git a/gui-clamp/ui-react/src/components/menu/MenuBar.js b/gui-clamp/ui-react/src/components/menu/MenuBar.js
index 769edb0..5ac5f88 100644
--- a/gui-clamp/ui-react/src/components/menu/MenuBar.js
+++ b/gui-clamp/ui-react/src/components/menu/MenuBar.js
@@ -37,24 +37,20 @@ const StyledLink = styled(Link)`
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ${ props => props.theme.menuHighlightedBackgroundColor };
color: ${ props => props.theme.menuHighlightedFontColor };
- }
-`;
+ }`;
const StyledNavLink = styled(Nav.Link)`
color: ${ props => props.theme.menuFontColor };
background-color: ${ props => props.theme.menuBackgroundColor };
font-weight: normal;
padding: .25rem 1.5rem;
-
:hover {
background-color: ${ props => props.theme.menuHighlightedBackgroundColor };
color: ${ props => props.theme.menuHighlightedFontColor };
- }
-`;
+ }`;
const StyledNavDropdown = styled(NavDropdown)`
color: ${ props => props.theme.menuFontColor };
@@ -67,8 +63,7 @@ const StyledNavDropdown = styled(NavDropdown)`
:hover {
font-weight: bold;
}
- }
-`;
+ }`;
export default class MenuBar extends React.Component {
state = {
diff --git a/gui-clamp/ui-react/src/components/menu/MenuBar.test.js b/gui-clamp/ui-react/src/components/menu/MenuBar.test.js
index bd55687..df1a17a 100644
--- a/gui-clamp/ui-react/src/components/menu/MenuBar.test.js
+++ b/gui-clamp/ui-react/src/components/menu/MenuBar.test.js
@@ -72,7 +72,7 @@ describe('Verify MenuBar', () => {
it('Finds POLICY Framework Menu', () => {
const component = shallow(<MenuBar />).childAt(4).dive();
- expect(component.find({ tile: 'TOSCA Control Loop' }));
+ expect(component.find({ tile: 'TOSCA Automation Composition' }));
});
it('Finds POLICY Framework Menu', () => {
@@ -84,4 +84,9 @@ describe('Verify MenuBar', () => {
const component = shallow(<MenuBar />);
expect(component.find('Styled(NavLink)').length).toEqual(2);
});
+
+ it('Finds StyledNavDropdown', () => {
+ const component = shallow(<MenuBar />);
+ expect(component.find('Styled(NavDropdown)').length).toEqual(6);
+ });
});
diff --git a/gui-clamp/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap b/gui-clamp/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap
index 86ae72d..336628d 100644
--- a/gui-clamp/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap
+++ b/gui-clamp/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap
@@ -31,7 +31,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -40,8 +39,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -100,7 +98,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -109,8 +106,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -168,7 +164,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -177,8 +172,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -237,7 +231,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -246,8 +239,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -302,7 +294,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -311,8 +302,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -367,7 +357,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -376,8 +365,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -432,7 +420,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -441,8 +428,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -500,7 +486,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -509,8 +494,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -565,7 +549,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -574,8 +557,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -634,7 +616,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -643,8 +624,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -699,7 +679,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -708,8 +687,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -764,7 +742,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -773,8 +750,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -829,7 +805,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -838,8 +813,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -897,7 +871,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -906,8 +879,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -962,7 +934,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -971,8 +942,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -1036,7 +1006,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -1045,8 +1014,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -1109,7 +1077,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -1118,8 +1085,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -1174,7 +1140,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -1183,8 +1148,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -1239,7 +1203,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -1248,8 +1211,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},
@@ -1319,7 +1281,6 @@ exports[`Verify MenuBar Test the render method 1`] = `
text-align: inherit;
white-space: nowrap;
border: 0;
-
:hover {
text-decoration: none;
background-color: ",
@@ -1328,8 +1289,7 @@ exports[`Verify MenuBar Test the render method 1`] = `
color: ",
[Function],
";
- }
-",
+ }",
],
"staticRulesId": "",
},