From 62bbf4d0aa4831f6bdd461011b71a4bb94724517 Mon Sep 17 00:00:00 2001 From: lapentafd Date: Wed, 23 Feb 2022 18:49:20 +0000 Subject: Code coverage apex editor Issue-ID: POLICY-3351 Signed-off-by: lapentafd Change-Id: Ib3043be521c37efe60e96b7917077db8c70b1645 --- .../js/__test__/ApexPolicyEditForm_State.test.js | 12 ++++++++++-- .../webapp/js/__test__/ApexTaskEditForm.test.js | 21 ++++++++++++++++++--- .../src/main/webapp/js/__test__/fileMenu.test.js | 7 +++++-- 3 files changed, 33 insertions(+), 7 deletions(-) (limited to 'gui-editors/gui-editor-apex') diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyEditForm_State.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyEditForm_State.test.js index 8b73319..24df8d0 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyEditForm_State.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyEditForm_State.test.js @@ -62,14 +62,22 @@ const policy = { version: 'testVersion', uuid: 'testUUID' }, - uuid: 'testUUID' + uuid: 'testUUID', + state: [{ key: 'testName1', value: '1'}, { key: 'testName2',value: '2'}] } const state = { trigger: { name: 'testName', version: '0.0.1', - } + }, + defaultTask: { + name: 'deftestName', + version: '0.0.2', + }, + taskReferences: [{key: { name: 'testName1',version: '1'}, key: { name: 'testName2',version: '2'}}], + stateOutputs : [{key: { name: 'testName1',version: '1'}, key: { name: 'testName2',version: '2'}}], + stateFinalizerLogicMap : [{key: {value: { logic: 'testName1', logicFlavour : '1'}}, key: {value: { logic: 'testName1', logicFlavour : '1'}}}] } const parentTBody = document.createElement('table'); diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskEditForm.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskEditForm.test.js index e9fcc9b..159dc71 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskEditForm.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskEditForm.test.js @@ -37,7 +37,17 @@ const task = { name: 'testName', version: 'testVersion' }, - uuid: 'testUUID' + uuid: 'testUUID', + description: 'Description of task', + taskLogic: { + logicFlavour: 'testFlav' + }, + inputFields : {entry: [{key: "key1", value: {fieldSchemaKey: { name : "name2", version : "version2"}}}]}, + outputFields : {entry: [{key: "key01", value: {fieldSchemaKey: { name : "name02", version : "version02"}}}]}, + taskParameters: {entry: [{key: 'testKey',value: {defaultValue: 'testValue'}}]}, + contextAlbumReference : [{name : 'contextEntry.name',version : 'contextEntry.version', displaytext : 'contextName'}, + {name : 'contextEntry.name2',version : 'contextEntry.version2', displaytext : 'contextName2'}, + {name : 'contextEntry.name3',version : 'contextEntry.version3', displaytext : 'contextName3'}] }; let data = { @@ -100,6 +110,9 @@ test('Test Edit Task Inner', () => { $.ajax = jest.fn().mockImplementation((args) => { args.success(data, null, jqXHR); }); + 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_editTask_inner); mock_activate('test', 'name', 'version', 'Edit'); expect(mock_activate).toBeCalled(); @@ -195,11 +208,13 @@ test('Test editTaskForm_submitPressed with page', () => { '' + ''; let documentSpy = jest.spyOn(document, 'getElementById'); - let elementMock = document.getElementById("editTaskFormInputFieldsTable"); + let elementMock = document.createElement("editTaskFormInputFieldsTable"); elementMock.value = 'notNullValue'; - elementMock.selectedOption = {"name": "name1", "version": "version1"}; + elementMock.selectedOption = {"name": "name1", "version": "version1", "displaytext": "t"}; elementMock.checked = {"name": "nameOpt", "version": "versionOpt"}; elementMock.setAttribute("createEditOrView", "EDIT") + elementMock.rows = document.getElementById("editTaskFormInputFieldsTable").rows; + console.log(elementMock.rows); documentSpy.mockReturnValue(elementMock); const mock_activate = jest.fn(mod.editTaskForm_submitPressed); diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/fileMenu.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/fileMenu.test.js index ffc9e2c..9f3c4b1 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/fileMenu.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/fileMenu.test.js @@ -21,11 +21,14 @@ const mod = require('../fileMenu'); test('test hideMenu', () => { - document.documentElement.innerHTML = ''; + document.documentElement.innerHTML = ''; $ = require('jquery'); window.$ = $; $('#menu').fileMenu(); - $('#menu').click(); + $('li').mouseenter(); + $('li').click(); + $('ul').mouseenter(); + $('ul').click(); let h1 = document.querySelector('ul'); expect(h1.textContent).toEqual('Hello world!'); }); -- cgit 1.2.3-korg