Create new VSP, onboard from TOSCA file - UI
[sdc.git] / openecomp-ui / test / softwareProduct / attachments / SoftwareProductAttachmentsView.test.js
1 /*!
2  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13  * or implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */
16
17 import React from 'react';
18 import TestUtils from 'react-addons-test-utils';
19 import {VSPAttachmentTreeNodeWithChildrenFactory, VSPAttachmentDetailedError} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js';
20 import {defaultStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js';
21
22 import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js';
23 import SoftwareProductAttachmentsView from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx';
24 import {tabsMapping} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js';
25 import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
26
27 describe('SoftwareProduct Attachments - View: ', function () {
28         it('should mapper exist', () => {
29                 expect(mapStateToProps).toBeTruthy();
30         });
31
32         it('should mapper return default data', () => {
33
34                 let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build();
35                 let errorList = VSPAttachmentDetailedError.buildList(3);
36                 let versionControllerData = VersionControllerUtilsFactory.build();
37
38                 let softwareProductAttachments = {
39                         attachmentsDetails: {activeTab: tabsMapping.SETUP},
40                         heatSetup: {},
41                         heatValidation: {
42                                 attachmentsTree,
43                                 errorList
44                         },
45                         heatSetupCache: {}
46                 };
47                 let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}});
48                 var result = mapStateToProps(data);
49                 expect(result).toBeTruthy();
50                 expect(result.isValidationAvailable).toBe(false);
51         });
52
53         it('view test', () => {
54
55                 let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build();
56                 let errorList = VSPAttachmentDetailedError.buildList(3);
57                 let versionControllerData = VersionControllerUtilsFactory.build();
58
59                 let softwareProductAttachments = {
60                         attachmentsDetails: {},
61                         heatSetup: {},
62                         heatValidation: {
63                                 attachmentsTree,
64                                 errorList
65                         },
66                         shouldOpenValidationTab: false
67                 };
68                 let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}});
69                 var params = mapStateToProps(data);
70
71                 var renderer = TestUtils.createRenderer();
72                 renderer.render(<SoftwareProductAttachmentsView {...params}/>);
73                 var renderedOutput = renderer.getRenderOutput();
74                 expect(renderedOutput).toBeTruthy();
75         });
76
77 });