diff options
Diffstat (limited to 'gui-editors/gui-editor-apex/src')
5 files changed, 54 insertions, 6 deletions
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameters.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameters.java index 3f988b5..58a4b33 100644 --- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameters.java +++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameters.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020-2021 Nordix Foundation. + * Modifications Copyright (C) 2020-2022 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,6 +27,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import lombok.Data; +import lombok.Generated; import org.apache.commons.lang3.StringUtils; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -37,6 +38,7 @@ import org.slf4j.ext.XLoggerFactory; * @author Liam Fallon (liam.fallon@ericsson.com) */ @Data +@Generated public class ApexEditorParameters { // Logger for this class private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexEditorParameters.class); diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexMain.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexMain.js index ce491ec..3fc3cd5 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexMain.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexMain.js @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020-2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -175,5 +175,6 @@ $(".ebInlineMessage").mouseleave(function(e) { }); export { - clearLocalStorage + clearLocalStorage, + main_getRestRootURL } diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexMain.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexMain.test.js index d26d926..beb73f5 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexMain.test.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexMain.test.js @@ -18,9 +18,11 @@ */ const mod = require('../ApexMain'); - +const $ = require('jquery'); test('Test main_getRestRootURL', () => { + jest.spyOn(window.localStorage.__proto__, 'getItem'); + window.localStorage.__proto__.getItem = jest.fn(() => true); const mock_main_getRestRootURL = jest.fn(mod.main_getRestRootURL); mock_main_getRestRootURL(); expect(mock_main_getRestRootURL).toBeCalled(); @@ -30,4 +32,13 @@ test('Test clearLocalStorage', () => { const mock_clearLocalStorage = jest.fn(mod.clearLocalStorage); mock_clearLocalStorage(); expect(mock_clearLocalStorage).toBeCalled(); +}); + +test('test ready', () => { + document.documentElement.innerHTML = '<html><head></head><body><ul id="menu li"><li><div>menu</div><ul><li><div>FileNew</div></li></ul></li></ul></body></html>'; + window.$ = $; + $("#menu li").click(); + let h1 = document.querySelector('ul'); + console.log(document.documentElement.innerHTML); + expect(h1.textContent).toEqual('menuFileNew'); });
\ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/fileMenu.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/fileMenu.test.js new file mode 100644 index 0000000..ffc9e2c --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/fileMenu.test.js @@ -0,0 +1,31 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +const mod = require('../fileMenu'); + +test('test hideMenu', () => { + document.documentElement.innerHTML = '<html><head></head><body><ul id="menu">Hello world!</ul></body></html>'; + $ = require('jquery'); + window.$ = $; + $('#menu').fileMenu(); + $('#menu').click(); + let h1 = document.querySelector('ul'); + expect(h1.textContent).toEqual('Hello world!'); +}); diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/showhideElement.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/showhideElement.test.js index 5f85a70..6b2bfa5 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/showhideElement.test.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/showhideElement.test.js @@ -29,8 +29,11 @@ test('Test editTaskForm_activate CREATE', () => { test('Test editTaskForm_activate NO CHECKBOX', () => { const mock_activate = jest.fn(mod.showHideElement_display); - let documentSpy = jest.spyOn(document, 'getElementById'); - mock_activate(documentSpy, null, null, 'hidestyle', 'buttonshowStyle','buttonhideStyle'); + spyOn($.fn, "find").and.returnValue(false); + const mockedElementDOM = { classList: { contains: jest.fn(), remove: jest.fn(), add: jest.fn() } }; + mockedElementDOM.classList.contains.mockReturnValueOnce(true); + mockedElementDOM.classList.remove.mockReturnValueOnce(true); + mock_activate(mockedElementDOM, 'element', 'style', 'hidestyle', 'buttonshowStyle','buttonhideStyle'); expect(mock_activate).toBeCalled(); }); |