Add new code new version
[sdc.git] / openecomp-ui / test / softwareProduct / components / general / SoftwareProductComponentsGeneral.test.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 import expect from 'expect';
22 import React from 'react';
23 import TestUtils from 'react-addons-test-utils';
24 import {mapStateToProps}  from 'sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneral.js';
25 import SoftwareProductComponentsGeneralView from 'sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneralView.jsx';
26 import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
27
28
29 describe('SoftwareProductComponentsGeneral Mapper and View Classes', () => {
30         it('mapStateToProps mapper exists', () => {
31                 expect(mapStateToProps).toExist();
32         });
33
34         it('mapStateToProps data test', () => {
35
36                 const currentSoftwareProduct = {
37                         name: 'VSp',
38                         description: 'dfdf',
39                         vendorName: 'V1',
40                         vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
41                         category: 'resourceNewCategory.application l4+',
42                         subCategory: 'resourceNewCategory.application l4+.database',
43                         id: 'D4774719D085414E9D5642D1ACD59D20',
44                         version: '0.10',
45                         viewableVersions: ['0.1', '0.2'],
46                         status: versionStatusEnum.CHECK_OUT_STATUS,
47                         lockingUser: 'cs0008'
48                 };
49
50                 var obj = {
51                         softwareProduct: {
52                                 softwareProductEditor: {
53                                         data: currentSoftwareProduct
54                                 },
55                                 softwareProductComponents: {
56                                         componentEditor: {
57                                                 data: {},
58                                                 qdata: {},
59                                                 qschema: {}
60                                         }
61                                 }
62                         }
63                 };
64
65                 var results = mapStateToProps(obj);
66                 expect(results.componentData).toExist();
67                 expect(results.qdata).toExist();
68                 expect(results.qschema).toExist();
69         });
70
71
72         it('VSP Components general view test', () => {
73
74                 const currentSoftwareProduct = {
75                         name: 'VSp',
76                         description: 'dfdf',
77                         vendorName: 'V1',
78                         vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
79                         category: 'resourceNewCategory.application l4+',
80                         subCategory: 'resourceNewCategory.application l4+.database',
81                         id: 'D4774719D085414E9D5642D1ACD59D20',
82                         version: '0.10',
83                         viewableVersions: ['0.1', '0.2'],
84                         status: versionStatusEnum.CHECK_OUT_STATUS,
85                         lockingUser: 'cs0008'
86                 };
87
88                 const softwareProductComponents = {
89                         componentEditor: {
90                                 data: {},
91                                 qdata: {},
92                                 qschema: {
93                                         $schema: 'http://json-schema.org/draft-04/schema#',
94                                         type: 'object',
95                                         properties: {
96                                                 general: {
97                                                         type: 'object',
98                                                         properties: {}
99                                                 }
100                                         }
101                                 }
102                         }
103                 };
104
105                 const versionControllerData = {
106                         version: '1',
107                         viewableVersions: [],
108                         status: 'locked',
109                         isCheckedOut: true
110                 };
111
112                 const componentData = {
113                         name: '',
114                         description: ''
115                 };
116
117                 var renderer = TestUtils.createRenderer();
118                 renderer.render(
119                         <SoftwareProductComponentsGeneralView
120                                 componentData={componentData}
121                                 softwareProductComponents={softwareProductComponents}
122                                 versionControllerData={versionControllerData}
123                                 currentSoftwareProduct={currentSoftwareProduct}/>);
124                 var renderedOutput = renderer.getRenderOutput();
125                 expect(renderedOutput).toExist();
126
127         });
128
129 });