blob: 355a3162b1ad5fd8d78d213960f325342794968f [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001/*!
Michael Landoefa037d2017-02-19 12:57:33 +02002 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
AviZi280f8012017-06-09 02:39:56 +03007 *
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,
AviZi280f8012017-06-09 02:39:56 +030012 * 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.
Michael Landoefa037d2017-02-19 12:57:33 +020015 */
16
Michael Landoefa037d2017-02-19 12:57:33 +020017import React from 'react';
18import TestUtils from 'react-addons-test-utils';
AviZi280f8012017-06-09 02:39:56 +030019import {VSPAttachmentTreeNodeWithChildrenFactory, VSPAttachmentDetailedError} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js';
20import {defaultStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js';
Michael Landoefa037d2017-02-19 12:57:33 +020021
AviZi280f8012017-06-09 02:39:56 +030022import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js';
Michael Landoefa037d2017-02-19 12:57:33 +020023import SoftwareProductAttachmentsView from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx';
AviZi280f8012017-06-09 02:39:56 +030024import {tabsMapping} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js';
25import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
Michael Landoefa037d2017-02-19 12:57:33 +020026
AviZi280f8012017-06-09 02:39:56 +030027describe('SoftwareProduct Attachments - View: ', function () {
28 it('should mapper exist', () => {
29 expect(mapStateToProps).toBeTruthy();
Michael Landoefa037d2017-02-19 12:57:33 +020030 });
31
AviZi280f8012017-06-09 02:39:56 +030032 it('should mapper return default data', () => {
Michael Landoefa037d2017-02-19 12:57:33 +020033
AviZi280f8012017-06-09 02:39:56 +030034 let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build();
35 let errorList = VSPAttachmentDetailedError.buildList(3);
36 let versionControllerData = VersionControllerUtilsFactory.build();
Michael Landoefa037d2017-02-19 12:57:33 +020037
AviZi280f8012017-06-09 02:39:56 +030038 let softwareProductAttachments = {
shrek2000c8a540b2017-09-11 15:45:37 +030039 attachmentsDetails: {activeTab: tabsMapping.SETUP},
AviZi280f8012017-06-09 02:39:56 +030040 heatSetup: {},
41 heatValidation: {
42 attachmentsTree,
43 errorList
Michael Landoefa037d2017-02-19 12:57:33 +020044 },
shrek2000c8a540b2017-09-11 15:45:37 +030045 heatSetupCache: {}
Michael Landoefa037d2017-02-19 12:57:33 +020046 };
AviZi280f8012017-06-09 02:39:56 +030047 let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}});
48 var result = mapStateToProps(data);
49 expect(result).toBeTruthy();
50 expect(result.isValidationAvailable).toBe(false);
Michael Landoefa037d2017-02-19 12:57:33 +020051 });
52
AviZi280f8012017-06-09 02:39:56 +030053 it('view test', () => {
Michael Landoefa037d2017-02-19 12:57:33 +020054
AviZi280f8012017-06-09 02:39:56 +030055 let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build();
56 let errorList = VSPAttachmentDetailedError.buildList(3);
57 let versionControllerData = VersionControllerUtilsFactory.build();
Michael Landoefa037d2017-02-19 12:57:33 +020058
AviZi280f8012017-06-09 02:39:56 +030059 let softwareProductAttachments = {
shrek2000c8a540b2017-09-11 15:45:37 +030060 attachmentsDetails: {},
AviZi280f8012017-06-09 02:39:56 +030061 heatSetup: {},
62 heatValidation: {
63 attachmentsTree,
64 errorList
Michael Landoefa037d2017-02-19 12:57:33 +020065 },
AviZi280f8012017-06-09 02:39:56 +030066 shouldOpenValidationTab: false
67 };
68 let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}});
69 var params = mapStateToProps(data);
Michael Landoefa037d2017-02-19 12:57:33 +020070
71 var renderer = TestUtils.createRenderer();
AviZi280f8012017-06-09 02:39:56 +030072 renderer.render(<SoftwareProductAttachmentsView {...params}/>);
Michael Landoefa037d2017-02-19 12:57:33 +020073 var renderedOutput = renderer.getRenderOutput();
AviZi280f8012017-06-09 02:39:56 +030074 expect(renderedOutput).toBeTruthy();
Michael Landoefa037d2017-02-19 12:57:33 +020075 });
76
77});