From d24453b1f0982763ceb5c52f7057899dfd6852c3 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Tue, 4 Sep 2018 14:16:51 +0530 Subject: utility.service.spec.ts : added test case 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 --- .../utilityService/utility.service.spec.ts | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/app/shared') diff --git a/src/app/shared/services/utilityService/utility.service.spec.ts b/src/app/shared/services/utilityService/utility.service.spec.ts index c0cdb13..6523447 100644 --- a/src/app/shared/services/utilityService/utility.service.spec.ts +++ b/src/app/shared/services/utilityService/utility.service.spec.ts @@ -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 -- cgit 1.2.3-korg