utility.service.spec.ts : added test case 59/64359/2
authorArundathi Patil <arundpil@in.ibm.com>
Tue, 4 Sep 2018 08:46:51 +0000 (14:16 +0530)
committerTakamune Cho <tc012c@att.com>
Tue, 4 Sep 2018 19:02:26 +0000 (19:02 +0000)
added test case to cover the condition when artifact-type is
reference-data in createPayLoadForSave() function.

Issue-ID: APPC-1064
Change-Id: I48b799c527cb93a1e186e6f649dc298ad1d0a90c
Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
src/app/shared/services/utilityService/utility.service.spec.ts

index c0cdb13..6523447 100644 (file)
@@ -110,4 +110,28 @@ describe('UtilityService', () => {
         expect(spy).toHaveBeenCalled();
 
     }));
+
+    it('should test createPayLoadForSave function', inject([UtilityService], (service: UtilityService) => {
+        let artifactContent = {data: 'data'};
+        let artifactType = 'reference_data';
+        let vnfType = 'vnf-type';
+        let action = 'config';
+        let fileName = 'referencedata.json';
+        let versionNo = 180;
+        localStorage.setItem('apiToken', 'dshagsa'); 
+        localStorage.setItem('userId', 'abc');         
+        let newPayload='{"userID": "' + 'abc' + '","vnf-type" : "' + vnfType + '","action" : "AllAction","artifact-name" : "' + fileName.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '","artifact-type" : "APPC-CONFIG","artifact-version" : "0.1","artifact-contents" :" ' + artifactContent + '"}';
+        let data =
+        {
+          "input": {
+            "design-request": {
+              "request-id": 'dshagsa',
+              "action": "uploadArtifact",
+              "payload": newPayload
+
+            }
+          }
+        }
+        let payload = service.createPayLoadForSave(artifactType, vnfType, action, fileName, versionNo, artifactContent);
+    }));
 });
\ No newline at end of file