From 29df248caa234bc0dff3c20875bdaecfeba127e0 Mon Sep 17 00:00:00 2001 From: lapentafd Date: Wed, 16 Feb 2022 10:39:50 +0000 Subject: Fix test duplication in policy gui Deleting some duplicationg tests, and fixing test skipping Issue-ID: POLICY-3351 Signed-off-by: lapentafd Change-Id: I2a9ac9061eaffdf70a1b6bff053dae287b895314 --- .../js/__test__/ApexPolicyEditForm_State.test.js | 91 +++++----------------- 1 file changed, 19 insertions(+), 72 deletions(-) (limited to 'gui-editors') 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 = '' + - '
' + - '
' + - '' + - '' + - '' + - '' + - '
cell 1cell 2
cell 3cell4
cell 5cell6
' + - ''; - - 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 = '' + '' + @@ -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 = '' + - '
' + + '
' + + '
' + + '
' + '' + '' + '' + '
cell 1cell 2
cell 3cell4
cell 5cell6
' + + '
' + ''; 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'); +}); -- cgit 1.2.3-korg