react-version-downgrade
[sdc.git] / openecomp-ui / test / softwareProduct / attachments / SoftwareProductAttachmentsView.test.js
1 /*
2  * Copyright © 2016-2017 European Support Limited
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 or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 import React from 'react';
18
19 import TestUtils from 'react-addons-test-utils';
20 import {VSPAttachmentTreeNodeWithChildrenFactory, VSPAttachmentDetailedError} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js';
21 import {defaultStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js';
22
23 import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js';
24 import SoftwareProductAttachmentsView from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx';
25 import {tabsMapping} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js';
26 import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
27
28 describe('SoftwareProduct Attachments - View: ', function () {
29         it('should mapper exist', () => {
30                 expect(mapStateToProps).toBeTruthy();
31         });
32
33         it('should mapper return default data', () => {
34
35                 let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build();
36                 let errorList = VSPAttachmentDetailedError.buildList(3);
37                 let versionControllerData = VersionControllerUtilsFactory.build();
38
39                 let softwareProductAttachments = {
40                         attachmentsDetails: {activeTab: tabsMapping.SETUP},
41                         heatSetup: {},
42                         heatValidation: {
43                                 attachmentsTree,
44                                 errorList
45                         },
46                         heatSetupCache: {}
47                 };
48                 let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}});
49                 var result = mapStateToProps(data);
50                 expect(result).toBeTruthy();
51                 expect(result.isValidationAvailable).toBe(false);
52         });
53
54         it('view test', () => {
55
56                 let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build();
57                 let errorList = VSPAttachmentDetailedError.buildList(3);
58                 let versionControllerData = VersionControllerUtilsFactory.build();
59
60                 let softwareProductAttachments = {
61                         attachmentsDetails: {},
62                         heatSetup: {},
63                         heatValidation: {
64                                 attachmentsTree,
65                                 errorList
66                         },
67                         shouldOpenValidationTab: false
68                 };
69                 let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}});
70                 var params = mapStateToProps(data);
71
72                 var renderer = TestUtils.createRenderer();
73                 renderer.render(<SoftwareProductAttachmentsView {...params}/>);
74                 var renderedOutput = renderer.getRenderOutput();
75                 expect(renderedOutput).toBeTruthy();
76         });
77
78 });