summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.reducers.spec.ts
blob: 30ad016f73900793995dd050a19ee313182cde26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import {relatedVnfMemeberReducer} from "./relatedVnfMember.reducers";
import {
  CreateRelatedVnfMemeberInstanceAction,
  DeleteActionRelatedVnfMemeberInstanceAction,
  RelatedVnfActions,
  UndoDeleteActionRelatedVnfMemeberInstanceAction
} from "./relatedVnfMember.actions";
import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";


describe('relatedVnfMemberReducer', () => {

  test('#DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE should change action to delete',() => {
    const serviceUuid: string = 'serviceUuid';
    const actionName: ServiceInstanceActions = ServiceInstanceActions.None;

    let service = relatedVnfMemeberReducer(<any>{
      serviceInstance: {
        'serviceUuid': {
          'vnfGroups' : {
            'vnfGroupStoreKey' : {
              'vnfs' : {
                'vnfStoreKey1' : {
                  'action' : actionName
                }
              }
            }

          }
        }
      }
    }, <DeleteActionRelatedVnfMemeberInstanceAction>{
      type: RelatedVnfActions.DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE,
      vnfGroupStoreKey: 'vnfGroupStoreKey',
      relatedVnfMemeberStoreKey : 'vnfStoreKey1',
      serviceId : 'serviceUuid'
    });

    expect(service.serviceInstance[serviceUuid].vnfGroups['vnfGroupStoreKey']['vnfs']['vnfStoreKey1'].action).toEqual('None_Delete');
  });

  test('#UNDO_DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE should undo change action to delete', () => {
    const serviceUuid: string = 'serviceUuid';
    const actionName: ServiceInstanceActions = ServiceInstanceActions.None_Delete;

    let service = relatedVnfMemeberReducer(<any>{
      serviceInstance: {
        'serviceUuid': {
          'vnfGroups' : {
            'vnfGroupStoreKey' : {
              'vnfs' : {
                'vnfStoreKey1' : {
                  'action' : actionName
                }
              }
            }

          }
        }
      }
    }, <UndoDeleteActionRelatedVnfMemeberInstanceAction>{
      type: RelatedVnfActions.UNDO_DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE,
      vnfGroupStoreKey: 'vnfGroupStoreKey',
      relatedVnfMemeberStoreKey : 'vnfStoreKey1',
      serviceId : 'serviceUuid'
    });

    expect(service.serviceInstance[serviceUuid].vnfGroups['vnfGroupStoreKey']['vnfs']['vnfStoreKey1'].action).toEqual('None');
  });

  test('#REMOVE_RELATED_VNF_MEMBER_INSTANCE should remove instance', () => {
    const serviceUuid: string = 'serviceUuid';
    const actionName: ServiceInstanceActions = ServiceInstanceActions.None_Delete;

    let service = relatedVnfMemeberReducer(<any>{
      serviceInstance: {
        'serviceUuid': {
          'vnfGroups' : {
            'vnfGroupStoreKey' : {
              'vnfs' : {
                'vnfStoreKey1' : {
                  'action' : actionName
                }
              }
            }

          }
        }
      }
    }, <UndoDeleteActionRelatedVnfMemeberInstanceAction>{
      type: RelatedVnfActions.UNDO_DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE,
      vnfGroupStoreKey: 'vnfGroupStoreKey',
      relatedVnfMemeberStoreKey : 'vnfStoreKey1',
      serviceId : 'serviceUuid'
    });

    expect(service.serviceInstance[serviceUuid].vnfGroups['vnfGroupStoreKey']['vnfs']['vnfStoreKey1'].action).toEqual('None');
  });

  test('#CREATE_RELATED_VNF_MEMBER_INSTANCE should add new relatedVNF instance', () => {
    const serviceUuid: string = 'serviceUuid';
    const actionName: ServiceInstanceActions = ServiceInstanceActions.None_Delete;
    let relatedVnfMember =  {
      "instanceName":"VNF1_INSTANCE_NAME",
      "instanceId":"VNF1_INSTANCE_ID",
      "orchStatus":null,
      "productFamilyId":null,
      "lcpCloudRegionId":"hvf23b",
      "tenantId":"3e9a20a3e89e45f884e09df0cc2d2d2a",
      "tenantName":"APPC-24595-T-IST-02C",
      "modelInfo":{
        "modelInvariantId":"vnf-instance-model-invariant-id",
        "modelVersionId":"7a6ee536-f052-46fa-aa7e-2fca9d674c44",
        "modelVersion":"2.0",
        "modelName":"vf_vEPDG",
        "modelType":"vnf"
      },
      "instanceType":"VNF1_INSTANCE_TYPE",
      "provStatus":null,
      "inMaint":false,
      "uuid":"7a6ee536-f052-46fa-aa7e-2fca9d674c44",
      "originalName":null,
      "legacyRegion":null,
      "lineOfBusiness":null,
      "platformName":null,
      "trackById":"7a6ee536-f052-46fa-aa7e-2fca9d674c44:002",
      "serviceInstanceId":"service-instance-id1",
      "serviceInstanceName":"service-instance-name"
    };

    let service = relatedVnfMemeberReducer(<any>{
      serviceInstance: {
        'serviceUuid': {
          'vnfGroups' : {
            'vnfGroupStoreKey' : { }
          }
        }
      }
    }, <CreateRelatedVnfMemeberInstanceAction>{
      type: RelatedVnfActions.CREATE_RELATED_VNF_MEMBER_INSTANCE,
      relatedVnfMember: relatedVnfMember,
      vnfGroupStoreKey: 'vnfGroupStoreKey',
      serviceId: serviceUuid
    });

    expect(service.serviceInstance[serviceUuid].vnfGroups['vnfGroupStoreKey']['vnfs']['VNF1_INSTANCE_ID'].action).toEqual('Create');
    expect(service.serviceInstance[serviceUuid].vnfGroups['vnfGroupStoreKey']['vnfs']['VNF1_INSTANCE_ID'].instanceId).toEqual('VNF1_INSTANCE_ID');
  });

});