diff options
author | Liam Fallon <liam.fallon@est.tech> | 2022-03-15 12:36:10 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2022-03-15 12:36:10 +0000 |
commit | 2f8b6cb2cb865abb850f5828fda584bd9238efbe (patch) | |
tree | 0c3142e1d7d367bf914754cf6f7f7e0d5ea08e4b /gui-clamp | |
parent | 93b5533e44728faa87c291fbf44120ea013fab51 (diff) | |
parent | 1e27cabdaf7c89a2c7381c8a46697be007778445 (diff) |
Merge "Added more unit tests for overall coverage"
Diffstat (limited to 'gui-clamp')
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": "", }, |