[SDC-29] Amdocs OnBoard 1707 initial commit.
[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                         heatSetup: {},
40                         heatValidation: {
41                                 attachmentsTree,
42                                 errorList
43                         },
44                         heatSetupCache: {},
45                         activeTab: tabsMapping.SETUP
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                         heatSetup: {},
61                         heatValidation: {
62                                 attachmentsTree,
63                                 errorList
64                         },
65                         shouldOpenValidationTab: false
66                 };
67                 let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}});
68                 var params = mapStateToProps(data);
69
70                 var renderer = TestUtils.createRenderer();
71                 renderer.render(<SoftwareProductAttachmentsView {...params}/>);
72                 var renderedOutput = renderer.getRenderOutput();
73                 expect(renderedOutput).toBeTruthy();
74         });
75
76 });