2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 import expect from 'expect';
22 import React from 'react';
23 import TestUtils from 'react-addons-test-utils';
24 import {mapStateToProps} from 'sdc-app/flows/FlowsListEditor.js';
25 import FlowsListEditorView from 'sdc-app/flows/FlowsListEditorView.jsx';
27 describe('Flows List Editor Mapper and View Classes: ', function () {
29 it('mapStateToProps mapper exists', () => {
30 expect(mapStateToProps).toExist();
33 it('mapStateToProps mapper - without flowList', () => {
36 isModalInEditMode: false,
37 shouldShowWorkflowsEditor: undefined
39 let results = mapStateToProps({flows});
40 expect(results.flowList).toExist();
41 expect(results.flowList.length).toEqual(0);
42 expect(results.shouldShowWorkflowsEditor).toBe(true);
45 it('mapStateToProps mapper - populated flowList', () => {
46 let artifactName = 'test1', description = 'desc';
48 flowList: [{artifactName, description}],
50 isModalInEditMode: false,
51 shouldShowWorkflowsEditor: false
53 let results = mapStateToProps({flows});
54 expect(results.flowList).toExist();
55 expect(results.flowList.length).toEqual(1);
56 expect(results.shouldShowWorkflowsEditor).toBe(false);
59 it('mapStateToProps mapper - populated flowList and currentFlow is in readonly', () => {
60 let artifactName = 'test1', description = 'desc';
61 let currentFlow = {artifactName, description, readonly: true};
63 flowList: [currentFlow],
66 isModalInEditMode: false,
67 shouldShowWorkflowsEditor: false
69 let results = mapStateToProps({flows});
70 expect(results.currentFlow).toExist();
71 expect(results.isCheckedOut).toEqual(false);
74 it('mapStateToProps mapper - populated flowList and currentFlow is in not readonly', () => {
75 let artifactName = 'test1', description = 'desc';
76 let currentFlow = {artifactName, description, readonly: false};
78 flowList: [currentFlow],
81 isModalInEditMode: false,
82 shouldShowWorkflowsEditor: false
84 let results = mapStateToProps({flows});
85 expect(results.currentFlow).toExist();
86 expect(results.isCheckedOut).toEqual(true);
89 it('basic view component run with empty flowList and should show the list', () => {
90 let renderer = TestUtils.createRenderer();
91 let artifactName = 'test1', description = 'desc';
92 let currentFlow = {artifactName, description, readonly: false};
93 renderer.render(<FlowsListEditorView shouldShowWorkflowsEditor={true} flowList={[currentFlow]}/>);
94 let renderedOutput = renderer.getRenderOutput();
95 expect(renderedOutput).toExist();
98 it('basic view component run with empty flowList and should show the diagram', () => {
100 'artifactType': 'WORKFLOW',
112 'name': 'Infrastructure'
147 'serviceID': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b',
148 'artifactDisplayName': 'zizizi',
149 'artifactGroupType': 'INFORMATIONAL',
150 'uniqueId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
151 'artifactName': 'zizizi',
152 'artifactLabel': 'zizizi',
153 'artifactUUID': '0295a7cc-8c02-4105-9d7e-c30ce67ecd07',
154 'artifactVersion': '1',
155 'creationDate': 1470144601623,
156 'lastUpdateDate': 1470144601623,
157 'description': 'aslkjdfl asfdasdf',
160 'esId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
161 'artifactChecksum': 'NjBmYjc4NGM5MWIwNmNkMDhmMThhMDAwYmQxYjBiZTU=',
162 'heatParameters': [],
163 'sequenceDiagramModel': {
166 'id': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
185 'name': 'Infrastructure',
241 'id': '9377-5036-c011-cb95-3a8b-82c6-bbb5-bc84',
242 'name': '[Unnamed Message]',
251 'id': '64c4-4fd1-b1da-4355-a060-6e48-ee47-c85c',
252 'name': '[Unnamed Message]',
263 let renderer = TestUtils.createRenderer();
264 renderer.render(<FlowsListEditorView currentFlow={flow} shouldShowWorkflowsEditor={false} flowList={[flow]}/>);
265 let renderedOutput = renderer.getRenderOutput();
266 expect(renderedOutput).toExist();
269 it('basic view component run with empty flowList and should show popup modal', () => {
270 let renderer = TestUtils.createRenderer();
271 let artifactName = 'test1', description = 'desc';
272 let currentFlow = {artifactName, description, readonly: false};
273 renderer.render(<FlowsListEditorView isDisplayModal={true} shouldShowWorkflowsEditor={true} flowList={[currentFlow]}/>);
274 let renderedOutput = renderer.getRenderOutput();
275 expect(renderedOutput).toExist();