Convert template summary from json to string.
[vid.git] / vid-webpack-master / src / app / shared / components / genericFormPopup / instantiationTemplatesModal / instantiation.templates.modal.service.spec.ts
index 1ff0f61..6540a65 100644 (file)
@@ -54,6 +54,17 @@ describe('instantiation templates modal service', () => {
     expect(service).toBeDefined();
   });
 
+  test('convert map to json', () => {
+    let result:InstantiationTemplatesRowModel = new InstantiationTemplatesRowModel({
+      "requestSummary": {
+        "vnf": 2,
+        "vfModule": 3,
+        "network": 1
+      }
+    });
+    expect(result.summary).toEqual( "{\"vnf\":2,\"vfModule\":3,\"network\":1}");
+  });
+
 
   test('convertResponseToUI - should return table data', () => {
     const jobs = [{
@@ -92,7 +103,6 @@ describe('instantiation templates modal service', () => {
       "serviceModelName": "ComplexService",
       "serviceModelVersion": "1.0",
       "createdBulkDate": 1524995555000,
-      "isRetryEnabled": false
     }];
     const tableRows: InstantiationTemplatesRowModel[] = service.convertResponseToUI(jobs);
     expect(tableRows).toHaveLength(1);
@@ -130,4 +140,21 @@ describe('instantiation templates modal service', () => {
     expect(result.instanceName).toEqual('<Automatically generated>');
   });
 
+  test('filterByUserId should filter table data by userId: not empty list', () => {
+    const jobs : InstantiationTemplatesRowModel[] = [
+      new InstantiationTemplatesRowModel({userId : 'userId_1'}),
+      new InstantiationTemplatesRowModel({userId : 'userId'}),
+      new InstantiationTemplatesRowModel({userId : 'userId'}),
+      new InstantiationTemplatesRowModel({userId : 'userId_1'})
+    ];
+    let result: InstantiationTemplatesRowModel[] = service.filterByUserId('userId', jobs);
+    expect(result).toHaveLength(2);
+  });
+
+  test('filterByUserId should filter table data by userId:  empty list should return empty list', () => {
+    const jobs : InstantiationTemplatesRowModel[] = [];
+    let result: InstantiationTemplatesRowModel[] = service.filterByUserId('userId', jobs);
+    expect(result).toHaveLength(0);
+  });
+
 });