summaryrefslogtreecommitdiffstats
path: root/gui-editors/gui-editor-apex/src/main/resources
diff options
context:
space:
mode:
authorlapentafd <francesco.lapenta@est.tech>2022-02-16 10:39:50 +0000
committerlapentafd <francesco.lapenta@est.tech>2022-02-16 10:51:29 +0000
commit29df248caa234bc0dff3c20875bdaecfeba127e0 (patch)
tree6c0a99c1c0207d459363498443a9db58708ff303 /gui-editors/gui-editor-apex/src/main/resources
parentedbc7915cf7e5ccbdf5c8384c5404428a51da237 (diff)
Fix test duplication in policy gui
Deleting some duplicationg tests, and fixing test skipping Issue-ID: POLICY-3351 Signed-off-by: lapentafd <francesco.lapenta@est.tech> Change-Id: I2a9ac9061eaffdf70a1b6bff053dae287b895314
Diffstat (limited to 'gui-editors/gui-editor-apex/src/main/resources')
-rw-r--r--gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyEditForm_State.test.js91
1 files changed, 19 insertions, 72 deletions
diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyEditForm_State.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyEditForm_State.test.js
index b69bbe3..8b73319 100644
--- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyEditForm_State.test.js
+++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyEditForm_State.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.
@@ -117,27 +117,6 @@ test('Test editPolicyForm_State_addPolicyTask', () => {
});
-test('Test editPolicyForm_State_getDirectOutputMappingOptions', () => {
- let documentSpy = jest.spyOn(document, 'getElementById');
- let elementMock = document.createElement("editPolicyFormDirOutputsTable_stateName");
- elementMock.rows = '1'
- documentSpy.mockReturnValue(elementMock);
- const mock_activate = jest.fn(mod.editPolicyForm_State_getDirectOutputMappingOptions);
- mock_activate('stateName');
- expect(mock_activate).toBeCalled();
-
-});
-
-test('Test editPolicyForm_State_getStateBean', () => {
- let documentSpy = jest.spyOn(document, 'getElementById');
- let elementMock = document.createElement("editPolicyFormDirOutputsTable_stateName");
- elementMock.rows = '1'
- documentSpy.mockReturnValue(elementMock);
- const mock_activate = jest.fn(mod.editPolicyForm_State_getStateBean);
- mock_activate('stateName');
- expect(mock_activate).toBeCalled();
-});
-
test('Test editPolicyForm_State_getStateBean StateName is Null', () => {
jest.spyOn(global.console, 'error').mockImplementation(() => {});
mod.editPolicyForm_State_getStateBean(null);
@@ -147,49 +126,6 @@ test('Test editPolicyForm_State_getStateBean StateName is Null', () => {
global.console.error.mockRestore();
});
-test('Test editPolicyForm_State_getStateBean with mock', () => {
- let documentSpy = jest.spyOn(document, 'getElementById');
- let elementMock = document.createElement("editPolicyFormDirOutputsTable_stateName");
- elementMock.rows = '1'
- elementMock.key = {"name": "name1", "version": "version1"}
- documentSpy.mockReturnValue(elementMock);
- const mock_activate = jest.fn(mod.editPolicyForm_State_getStateBean);
- mock_activate('stateName');
- expect(mock_activate).toBeCalled();
-});
-
-
-test('Test editPolicyForm_State_getStateBean with page', () => {
- document.documentElement.innerHTML = '<html><head></head><body>' +
- '<div id="editPolicyFormStateDiv_stateName"></div>' +
- '<div id="editPolicyFormTrigger_stateName_dropdownList" selectedOption="1"></div>' +
- '<table id="editPolicyFormContextsTable_stateName"context_id="a0">' +
- '<tr class="table" context_id="a1" output_id="b1" finalizer_id="c1" task_id="d1"><td>cell 1</td><td>cell 2</td></tr>' +
- '<tr class="table" context_id="a2" output_id="b2" finalizer_id="c2" task_id="d2"><td>cell 3</td><td>cell4</td></tr>' +
- '<tr class="table" context_id="a3" output_id="b3" finalizer_id="c3" task_id="d3"><td>cell 5</td><td>cell6</td></tr>' +
- '</table>' +
- '</body></html>';
-
- let documentSpy = jest.spyOn(document, 'getElementById');
- let elementMock = document.createElement("editPolicyFormDirOutputsTable_stateName");
- elementMock.setAttribute("context_id", "a0");
- elementMock.setAttribute("task_id", "d0");
- elementMock.rows = document.getElementById("editPolicyFormContextsTable_stateName").rows;
- elementMock.key = {"name": "name1", "version": "version1"};
- elementMock.selectedOption = {"album": { "key": { "name": 'testAlbumName', "version": '0.0.1'}}, "name": "name1", "version": "version1", "event": { "key": { "name": 'testEventName', "version": '0.1.1'}}};
- elementMock.value = "localName";
- documentSpy.mockReturnValue(elementMock);
- const mock_activate = jest.fn(mod.editPolicyForm_State_getStateBean);
- mock_activate('stateName');
- expect(mock_activate).toBeCalled();
-});
-
-test('Test editPolicyForm_State_getLogicOutputMappingOptions', () => {
- const mock_activate = jest.fn(mod.editPolicyForm_State_getLogicOutputMappingOptions);
- mock_activate(null);
- expect(mock_activate).toBeCalled();
-});
-
test('Test editPolicyForm_State_getLogicOutputMappingOptions with page', () => {
document.documentElement.innerHTML = '<html><head></head><body>' +
'<table id="editPolicyFormLogicOutputsTable_stateName"context_id="a0">' +
@@ -205,23 +141,34 @@ test('Test editPolicyForm_State_getLogicOutputMappingOptions with page', () => {
documentSpy.mockReturnValue(elementMock);
const mock_activate = jest.fn(mod.editPolicyForm_State_getLogicOutputMappingOptions);
mock_activate('stateName');
- expect(mock_activate).toBeCalled();
+ expect(mock_activate).toBeCalledWith('stateName');
});
-test('Test editPolicyForm_State_getDirectOutputMappingOptions with page', () => {
+test('Test editPolicyForm_State_getStateBean with page', () => {
document.documentElement.innerHTML = '<html><head></head><body>' +
- '<table id="editPolicyFormDirOutputsTable_stateName"context_id="a0">' +
+ '<div id="editPolicyFormStateDiv_stateName"></div>' +
+ '<div id="editPolicyFormTrigger_stateName_dropdownList"></div>' +
+ '<table id="editPolicyFormContextsTable_stateName"context_id="a0">' +
'<tr class="table" context_id="a1" output_id="b1" finalizer_id="c1" task_id="d1"><td>cell 1</td><td>cell 2</td></tr>' +
'<tr class="table" context_id="a2" output_id="b2" finalizer_id="c2" task_id="d2"><td>cell 3</td><td>cell4</td></tr>' +
'<tr class="table" context_id="a3" output_id="b3" finalizer_id="c3" task_id="d3"><td>cell 5</td><td>cell6</td></tr>' +
'</table>' +
+ '<form id="test"><label><input type="radio" name="editPolicyFormTaskOutputType_stateName_d2" value="LOGIC" checked>LOGIC</label></form>' +
'</body></html>';
let documentSpy = jest.spyOn(document, 'getElementById');
let elementMock = document.createElement("editPolicyFormDirOutputsTable_stateName");
+ elementMock.setAttribute("context_id", "a0");
+ elementMock.setAttribute("task_id", "d0");
+ elementMock.rows = document.getElementById("editPolicyFormContextsTable_stateName").rows;
+ elementMock.key = {"name": "name1", "version": "version1"};
+ elementMock.selectedOption =
+ {"name": "name1", "version": "version1",
+ "album": { "key": { "name": 'testAlbumName', "version": '0.0.1'}},
+ "event": { "key": { "name": 'testEventName', "version": '0.1.1'}},
+ "task": { "key": { "name": 'tname', "version": '1.0.0'}}};
elementMock.value = "localName";
- elementMock.rows = document.getElementById("editPolicyFormDirOutputsTable_stateName").rows;
documentSpy.mockReturnValue(elementMock);
- const mock_activate = jest.fn(mod.editPolicyForm_State_getDirectOutputMappingOptions);
+ const mock_activate = jest.fn(mod.editPolicyForm_State_getStateBean);
mock_activate('stateName');
- expect(mock_activate).toBeCalled();
-}); \ No newline at end of file
+ expect(mock_activate).toBeCalledWith('stateName');
+});