Merge "ConfigurableViewReducer test"
authorJames Forsyth <jf2512@att.com>
Thu, 15 Aug 2019 13:55:13 +0000 (13:55 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 15 Aug 2019 13:55:13 +0000 (13:55 +0000)
package.json
pom.xml
test/app/MainScreenWrapperActionHelper.test.js [new file with mode: 0644]
test/app/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js
test/app/networking/NetworkCalls.test.js
version.properties

index 2b8334a..ef4d259 100644 (file)
@@ -48,6 +48,7 @@
     "redux": "^3.3.1",
     "redux-form": "^6.2.1",
     "redux-thunk": "^2.1.0",
+    "sinon": "^7.3.1",
     "topojson": "^2.2.0",
     "uuid-js": "^0.7.5",
     "validator": "^4.3.0",
diff --git a/pom.xml b/pom.xml
index 422b04f..725d77f 100644 (file)
--- a/pom.xml
+++ b/pom.xml
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onap.oparent</groupId>
+        <artifactId>oparent</artifactId>
+        <version>2.0.0</version>
+    </parent>
     <groupId>org.onap.aai</groupId>
     <artifactId>sparky-fe</artifactId>
     <packaging>war</packaging>
-    <version>1.4.0-SNAPSHOT</version>
+    <version>1.5.1-SNAPSHOT</version>
     <name>aai-sparky-fe</name>
     <url>http://maven.apache.org</url>
 
                             <goal>npm</goal>
                         </goals>
                         <phase>generate-resources</phase>
+                        <configuration>
+                           <!-- optional: The default argument is actually
+                                "install", so unless you need to run some other npm command,
+                                you can remove this whole <configuration> section.
+                           -->
+                           <arguments>install -ddd</arguments>
+                        </configuration>
+                       
                     </execution>
                     <execution>
                         <id>gulp build</id>
                 </executions>
             </plugin>
             <plugin>
-                <groupId>org.sonatype.plugins</groupId>
-                <artifactId>nexus-staging-maven-plugin</artifactId>
-                <version>1.6.7</version>
-                <extensions>true</extensions>
-                <configuration>
-                    <nexusUrl>${nexusproxy}</nexusUrl>
-                    <stagingProfileId>176c31dfe190a</stagingProfileId>
-                    <serverId>ecomp-staging</serverId>
-                </configuration>
+              <groupId>org.apache.maven.plugins</groupId>
+              <artifactId>maven-deploy-plugin</artifactId>
             </plugin>
         </plugins>
     </build>
diff --git a/test/app/MainScreenWrapperActionHelper.test.js b/test/app/MainScreenWrapperActionHelper.test.js
new file mode 100644 (file)
index 0000000..011010e
--- /dev/null
@@ -0,0 +1,132 @@
+import configureStore from 'redux-mock-store';
+import thunk from 'redux-thunk'
+import {
+  windowResize,
+  showMainMenu,
+  extensibleViewMessageCallback,
+  clearExtensibleViewData,
+  setSecondaryTitle
+} from 'app/MainScreenWrapperActionHelper';
+import {
+  getSetGlobalMessageEvent,
+  getClearGlobalMessageEvent
+} from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions';
+import {
+  globalInlineMessageBarActionTypes
+} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants';
+import {aaiActionTypes} from 'app/MainScreenWrapperConstants';
+
+const mockStore = configureStore([thunk]);
+
+describe('MainScreenWrapperActionHelper', () => {
+  let store;
+
+  beforeEach(() => {
+    store = mockStore({ tierSupportReducer: {} });
+  });
+
+  describe('windowResize', () => {
+    it('emits action', () => {
+      // Given
+      const expectedActions = [{
+        type: aaiActionTypes.AAI_WINDOW_RESIZE
+      }];
+
+      // When
+      store.dispatch(windowResize());
+
+      // Then
+      expect(store.getActions()).toEqual(expectedActions);
+    });
+  });
+
+  describe('showMainMenu', () => {
+    it('emits action with payload', () => {
+      // Given
+      const input = "testInput";
+      const expectedActions = [{
+        type: aaiActionTypes.AAI_SHOW_MENU,
+        data: {
+          showMenu: input
+        }
+      }];
+
+      // When
+      store.dispatch(showMainMenu(input));
+
+      // Then
+      expect(store.getActions()).toEqual(expectedActions);
+    });
+  });
+
+  describe('extensibleViewMessageCallback', () => {
+    const msgSeverity = "msgSeverity";
+
+    it('emits action with payload when msgText is not blank', () => {
+      // Given
+      const msgText = "msgText";
+      const expectedActions = [{
+        type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE,
+        data: {
+          msgText: msgText,
+          msgSeverity: msgSeverity
+        }
+      }];
+
+      // When
+      store.dispatch(extensibleViewMessageCallback(msgText, msgSeverity));
+
+      // Then
+      expect(store.getActions()).toEqual(expectedActions);
+    });
+
+    it('emits action when msgText is blank', () => {
+      // Given
+      const msgText = "";
+      const expectedActions = [{
+        type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE
+
+      }];
+
+      // When
+      store.dispatch(extensibleViewMessageCallback(msgText, msgSeverity));
+
+      // Then
+      expect(store.getActions()).toEqual(expectedActions);
+    });
+  });
+
+  describe('clearExtensibleViewData', () => {
+    it('emits action with payload', () => {
+      // Given
+      const expectedActions = [{
+        type: aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_CLEAR_DATA,
+        data: {}
+      }];
+
+      // When
+      store.dispatch(clearExtensibleViewData());
+
+      // Then
+      expect(store.getActions()).toEqual(expectedActions);
+    });
+  });
+
+  describe('setSecondaryTitle', () => {
+    it('emits action with payload', () => {
+      // Given
+      const title = "testTitle";
+      const expectedActions = [{
+        type: aaiActionTypes.SET_SECONDARY_TITLE,
+        data: title
+      }];
+
+      // When
+      store.dispatch(setSecondaryTitle(title));
+
+      // Then
+      expect(store.getActions()).toEqual(expectedActions);
+    });
+  });
+
+});
index 62389b4..bbcb7c1 100644 (file)
@@ -1,13 +1,14 @@
-import GlobalInlineMessageBarReducer from 'app/globalInlineMessageBar/GlobalInlineMessageBarReducer.js';
+import GlobalInlineMessageBarReducer from 'app/globalInlineMessageBar/GlobalInlineMessageBarReducer';
 import {
   globalInlineMessageBarActionTypes
-} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants.js';
+} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants';
 import {
   MESSAGE_LEVEL_WARNING
-} from 'utils/GlobalConstants.js'
+} from 'utils/GlobalConstants'
 
 describe('GlobalInlineMessageBarReducerTests', () => {
   it('Action Type: SET_GLOBAL_MESSAGE', () => {
+    // Given
     const action = {
       type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE,
       data: {
@@ -16,7 +17,11 @@ describe('GlobalInlineMessageBarReducerTests', () => {
       }
     };
     let state = {};
+
+    // When
     state = GlobalInlineMessageBarReducer(state, action);
+
+    // Then
     expect(state).toEqual({
       feedbackMsgText: action.data.msgText,
       feedbackMsgSeverity: action.data.msgSeverity
@@ -24,6 +29,7 @@ describe('GlobalInlineMessageBarReducerTests', () => {
   });
 
   it('Action Type: CLEAR_GLOBAL_MESSAGE', () => {
+    // Given
     const action = {
       type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE
     };
@@ -31,10 +37,31 @@ describe('GlobalInlineMessageBarReducerTests', () => {
       feedbackMsgText: 'some error message here',
       feedbackMsgSeverity: MESSAGE_LEVEL_WARNING
     };
+
+    // When
     state = GlobalInlineMessageBarReducer(state, action);
+
+    // Then
     expect(state).toEqual({
       feedbackMsgText: '',
       feedbackMsgSeverity: ''
     });
   });
-})
+
+  it('Action Type: unknown', () => {
+    // Given
+    const action = {
+      type: "TestUnknownType"
+    };
+    const initialState = {
+      feedbackMsgText: 'some error message here',
+      feedbackMsgSeverity: MESSAGE_LEVEL_WARNING
+    };
+
+    // When
+    const newState = GlobalInlineMessageBarReducer(initialState, action);
+
+    // Then
+    expect(newState).toEqual(initialState);
+  });
+});
index 373fbac..a3b6176 100644 (file)
@@ -90,34 +90,53 @@ describe("Network Utils", () => {
 
   describe('#getRequest', () => {
     it("should fetch any request", () => {
-      const json = suite.sandbox.stub();
-      const fetchPromise = Promise.resolve({json});
-      global.fetch = suite.sandbox.stub();
-
-      global.fetch
-      .withArgs('URL', {
-        credentials: 'same-origin',
-        method: 'GET'
-      })
-      .returns(fetchPromise);
-
-      NetworkCalls.getRequest("URL", "GET");
-
-      return fetchPromise.then(() => {
-        sinon.assert.calledOnce(json);
-      });
+        // given
+        global.fetch = suite.sandbox.stub();
+        const json = suite.sandbox.stub();
+        const url = "localhost";
+
+        global.fetch
+            .withArgs(url, {
+                credentials: 'same-origin',
+                method: 'GET'
+            })
+            .returns(json);
+
+        // when
+        const request = NetworkCalls.getRequest(url, "GET");
+
+        //then
+        expect(request).toBe(json)
+        sinon.assert.calledOnce(global.fetch);
     });
   });
 
   describe('#genericRequest', () => {
     it('should fetch any generic request', () => {
+      // given
       global.fetch = suite.sandbox.stub();
       const then = suite.sandbox.stub();
       fetch.returns({then});
+
+      // when
       NetworkCalls.genericRequest("localhost", "/relativeUrl", "GET");
 
+      // then
       expect(then.firstCall.args[0]({json: () => "d"})).toEqual("d");
+      sinon.assert.calledOnce(fetch);
+    });
 
+    it('should fetch any generic request - non relative', () => {
+      // given
+      global.fetch = suite.sandbox.stub();
+      const then = suite.sandbox.stub();
+      fetch.returns({then});
+
+      // when
+      NetworkCalls.genericRequest("localhost", false, "GET");
+
+      // then
+      expect(then.firstCall.args[0]({json: () => "d"})).toEqual("d");
       sinon.assert.calledOnce(fetch);
     });
   });
index 66827fd..4814eb2 100644 (file)
@@ -4,8 +4,8 @@
 # because they are used in Jenkins, whose plug-in doesn't support
 
 major_version=1
-minor_version=4
-patch_version=0
+minor_version=5
+patch_version=1
 
 base_version=${major_version}.${minor_version}.${patch_version}