diff options
author | 2022-01-04 08:45:27 +0000 | |
---|---|---|
committer | 2022-01-13 12:42:38 +0000 | |
commit | 608da1fe97427b55b0fee617237301d0bef86ae0 (patch) | |
tree | f6f5cdd6e8d70ee2c19fcd0164c7db913b1d8772 /gui-editors/gui-editor-apex/src/main/resources | |
parent | 3eb9e8975b8d9e1f44106b3c9c4c6d8b711ad3a2 (diff) |
Code coverage gui-editor-apex
Issue-ID: POLICY-3351
Change-Id: I51ae3b5e6de3f81af5cb445ade7309360da50afa
Signed-off-by: lapentafd <francesco.lapenta@est.tech>
Diffstat (limited to 'gui-editors/gui-editor-apex/src/main/resources')
3 files changed, 91 insertions, 4 deletions
diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexEventEditForm.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexEventEditForm.test.js index a203f06..bcf21e5 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexEventEditForm.test.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexEventEditForm.test.js @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2021 Nordix Foundation. + * 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. @@ -21,6 +21,7 @@ const mod = require('../ApexEventEditForm'); const eventTab_reset = require('../ApexEventTab'); const apexUtils = require('../ApexUtils'); +const formUtils_generateDescription = require('../ApexFormUtils'); const keyInformationTab_reset = require('../ApexKeyInformationTab'); let data = { @@ -135,4 +136,23 @@ test('Test Create Event', () => { const mock_activate = jest.fn(mod.editEventForm_createEvent); mock_activate('parentTest'); expect(mock_activate).toBeCalled(); -});
\ No newline at end of file +}); + +test('Test Edit Event Generate UUID Pressed', () => { + let documentSpy = jest.spyOn(document, 'getElementById'); + let elementMock = document.createElement("editContextSchemaFormDescriptionTextArea"); + documentSpy.mockReturnValue(elementMock); + const mock_activate = jest.fn(mod.editEventForm_generateUUIDPressed); + mock_activate(); + expect(mock_activate).toBeCalled(); +}); + +test('Test Edit Event Generate Description Pressed', () => { + jest.spyOn(formUtils_generateDescription, 'formUtils_generateDescription').mockReturnValueOnce(null); + let documentSpy = jest.spyOn(document, 'getElementById'); + let elementMock = document.createElement("editContextSchemaFormDescriptionTextArea"); + documentSpy.mockReturnValue(elementMock); + const mock_activate = jest.fn(mod.editEventForm_generateDescriptionPressed); + mock_activate(); + expect(mock_activate).toBeCalled(); +}); diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexTaskEditForm.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexTaskEditForm.test.js index ee90136..f7ac592 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexTaskEditForm.test.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexTaskEditForm.test.js @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2021 Nordix Foundation. + * 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. @@ -51,6 +51,13 @@ let data = { ok: true }; + let contextAlbumReference = { + "name" : "TestAlbum", + "version" : "0.0.1" +}; + +const parentTBody = document.createElement('table'); + test('Test editTaskForm_activate CREATE', () => { const mock_activate = jest.fn(mod.editTaskForm_activate); mock_activate('test', 'CREATE', 'task', contextSchema, 'album'); @@ -98,6 +105,59 @@ test('Test Edit Task Inner', () => { expect(mock_activate).toBeCalled(); }); +test('Test editTaskForm_addTaskInputField', () => { + const mock_activate = jest.fn(mod.editTaskForm_addTaskInputField); + let contextSchemas = new Array(); + contextSchemas.push(contextSchema); + mock_activate(parentTBody, true, 'name', null, contextSchema, contextSchemas); + expect(mock_activate).toBeCalled(); +}); + +test('Test editTaskForm_addTaskOutputField', () => { + const mock_activate = jest.fn(mod.editTaskForm_addTaskOutputField); + let contextSchemas = new Array(); + contextSchemas.push(contextSchema); + mock_activate(parentTBody, true, 'name', null, contextSchema, contextSchemas); + expect(mock_activate).toBeCalled(); +}); +test('Test editTaskForm_addTaskParameter', () => { + const mock_activate = jest.fn(mod.editTaskForm_addTaskParameter); + mock_activate(parentTBody, true, 'name', null); + expect(mock_activate).toBeCalled(); +}); +test('Test editTaskForm_addTaskContext', () => { + const mock_activate = jest.fn(mod.editTaskForm_addTaskContext); + let contextAlbums = new Array(); + contextAlbums.push(contextAlbumReference); + mock_activate(parentTBody, true, 'name', null, contextAlbumReference, contextAlbums); + expect(mock_activate).toBeCalled(); +}); +test('Test editTaskForm_generateUUIDPressed', () => { + let documentSpy = jest.spyOn(document, 'getElementById'); + let editTaskFormUuidInput = document.createElement("editTaskFormUuidInput"); + documentSpy.mockReturnValue(editTaskFormUuidInput); + const mock_activate = jest.fn(mod.editTaskForm_generateUUIDPressed); + mock_activate(); + expect(mock_activate).toBeCalled(); +}); + +test('Test editTaskForm_generateDescriptionPressed', () => { + let documentSpy = jest.spyOn(document, 'getElementById'); + let editTaskFormDescriptionTextArea = document.createElement("editTaskFormDescriptionTextArea"); + documentSpy.mockReturnValue(editTaskFormDescriptionTextArea); + const mock_activate = jest.fn(mod.editTaskForm_generateDescriptionPressed); + mock_activate(); + expect(mock_activate).toBeCalled(); +}); + +test('Test editTaskForm_cancelPressed', () => { + jest.spyOn(apexTaskTab, 'taskTab_reset').mockReturnValueOnce(null); + jest.spyOn(keyInformationTab_reset, 'keyInformationTab_reset').mockReturnValueOnce(null); + jest.spyOn(apexUtils, 'apexUtils_removeElement').mockReturnValueOnce(null); + const mock_activate = jest.fn(mod.editTaskForm_cancelPressed); + mock_activate(); + expect(mock_activate).toBeCalled(); +}); 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 4e4e811..117cbf7 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 @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021-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. @@ -27,6 +27,13 @@ test('Test editTaskForm_activate CREATE', () => { expect(mock_activate).toBeCalled(); }); +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'); + expect(mock_activate).toBeCalled(); +}); + |