blob: f610f6d298514ef42e32b2c337af30f0d0d0af8b [file] [log] [blame]
svishnev1eb66b72018-01-11 14:39:45 +02001/*
2 * Copyright © 2016-2017 European Support Limited
AviZi280f8012017-06-09 02:39:56 +03003 *
Michael Landoefa037d2017-02-19 12:57:33 +02004 * 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
svishnev1eb66b72018-01-11 14:39:45 +02007 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
Michael Landoefa037d2017-02-19 12:57:33 +020010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
svishnev1eb66b72018-01-11 14:39:45 +020012 * 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.
Michael Landoefa037d2017-02-19 12:57:33 +020015 */
16
Michael Landoefa037d2017-02-19 12:57:33 +020017import React from 'react';
svishnev1eb66b72018-01-11 14:39:45 +020018import ShallowRenderer from 'react-test-renderer/shallow';
19import TestUtils from 'react-dom/test-utils';
AviZi280f8012017-06-09 02:39:56 +030020import {VSPAttachmentTreeNodeWithChildrenFactory, VSPAttachmentDetailedError} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js';
21import {defaultStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js';
Michael Landoefa037d2017-02-19 12:57:33 +020022
AviZi280f8012017-06-09 02:39:56 +030023import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js';
Michael Landoefa037d2017-02-19 12:57:33 +020024import SoftwareProductAttachmentsView from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx';
AviZi280f8012017-06-09 02:39:56 +030025import {tabsMapping} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js';
26import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
Michael Landoefa037d2017-02-19 12:57:33 +020027
AviZi280f8012017-06-09 02:39:56 +030028describe('SoftwareProduct Attachments - View: ', function () {
29 it('should mapper exist', () => {
30 expect(mapStateToProps).toBeTruthy();
Michael Landoefa037d2017-02-19 12:57:33 +020031 });
32
AviZi280f8012017-06-09 02:39:56 +030033 it('should mapper return default data', () => {
Michael Landoefa037d2017-02-19 12:57:33 +020034
AviZi280f8012017-06-09 02:39:56 +030035 let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build();
36 let errorList = VSPAttachmentDetailedError.buildList(3);
37 let versionControllerData = VersionControllerUtilsFactory.build();
Michael Landoefa037d2017-02-19 12:57:33 +020038
AviZi280f8012017-06-09 02:39:56 +030039 let softwareProductAttachments = {
shrek2000c8a540b2017-09-11 15:45:37 +030040 attachmentsDetails: {activeTab: tabsMapping.SETUP},
AviZi280f8012017-06-09 02:39:56 +030041 heatSetup: {},
42 heatValidation: {
43 attachmentsTree,
44 errorList
Michael Landoefa037d2017-02-19 12:57:33 +020045 },
shrek2000c8a540b2017-09-11 15:45:37 +030046 heatSetupCache: {}
Michael Landoefa037d2017-02-19 12:57:33 +020047 };
AviZi280f8012017-06-09 02:39:56 +030048 let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}});
49 var result = mapStateToProps(data);
50 expect(result).toBeTruthy();
51 expect(result.isValidationAvailable).toBe(false);
Michael Landoefa037d2017-02-19 12:57:33 +020052 });
53
AviZi280f8012017-06-09 02:39:56 +030054 it('view test', () => {
Michael Landoefa037d2017-02-19 12:57:33 +020055
AviZi280f8012017-06-09 02:39:56 +030056 let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build();
57 let errorList = VSPAttachmentDetailedError.buildList(3);
58 let versionControllerData = VersionControllerUtilsFactory.build();
Michael Landoefa037d2017-02-19 12:57:33 +020059
AviZi280f8012017-06-09 02:39:56 +030060 let softwareProductAttachments = {
shrek2000c8a540b2017-09-11 15:45:37 +030061 attachmentsDetails: {},
AviZi280f8012017-06-09 02:39:56 +030062 heatSetup: {},
63 heatValidation: {
64 attachmentsTree,
65 errorList
Michael Landoefa037d2017-02-19 12:57:33 +020066 },
AviZi280f8012017-06-09 02:39:56 +030067 shouldOpenValidationTab: false
68 };
69 let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}});
70 var params = mapStateToProps(data);
Michael Landoefa037d2017-02-19 12:57:33 +020071
svishnev1eb66b72018-01-11 14:39:45 +020072 const renderer = new ShallowRenderer();
AviZi280f8012017-06-09 02:39:56 +030073 renderer.render(<SoftwareProductAttachmentsView {...params}/>);
Michael Landoefa037d2017-02-19 12:57:33 +020074 var renderedOutput = renderer.getRenderOutput();
AviZi280f8012017-06-09 02:39:56 +030075 expect(renderedOutput).toBeTruthy();
Michael Landoefa037d2017-02-19 12:57:33 +020076 });
77
78});