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/FlowsEditorModal.js';
25 import FlowsEditorModalView from 'sdc-app/flows/FlowsEditorModalView.jsx';
27 describe('Flows Editor Modal Mapper and View Classes: ', function () {
29 it('mapStateToProps mapper exists', () => {
30 expect(mapStateToProps).toExist();
33 it('mapStateToProps mapper - without currentFlow', () => {
36 diagramType: 'SOME_TYPE'
38 var results = mapStateToProps({flows});
39 expect(results.currentFlow).toExist();
40 expect(results.currentFlow.artifactName).toBe('');
41 expect(results.currentFlow.description).toBe('');
44 it('mapStateToProps mapper - populated currentFlow', () => {
45 let artifactName = 'test1', description = 'desc';
47 currentFlow: {artifactName, description},
49 diagramType: 'SOME_TYPE'
51 var results = mapStateToProps({flows});
52 expect(results.currentFlow).toExist();
53 expect(results.currentFlow.artifactName).toBe(artifactName);
54 expect(results.currentFlow.description).toBe(description);
55 expect(results.currentFlow.serviceID).toBe(flows.serviceID);
56 expect(results.currentFlow.artifactType).toBe(flows.diagramType);
59 it('basic modal view component run with empty artifact', () => {
60 let renderer = TestUtils.createRenderer();
64 onDataChanged={()=>{}}
65 currentFlow={{artifactName: '', description: ''}}/>);
66 let renderedOutput = renderer.getRenderOutput();
67 expect(renderedOutput).toExist();
70 it('modal view component run with data changed handler', done => {
71 let handler = () => done();
72 let document = TestUtils.renderIntoDocument(
75 onDataChanged={handler}
76 currentFlow={{artifactName: '', description: ''}}/>);
77 let result = TestUtils.scryRenderedDOMComponentsWithTag(document, 'input');
78 expect(result).toExist();
79 expect(result.length).toExist();
80 TestUtils.Simulate.change(result[0]);
83 it('modal view component - on save click', done => {
84 let handler = () => done();
85 var flowsEditorModalView = new FlowsEditorModalView({currentFlow: {}, onSubmit: handler});
86 flowsEditorModalView.onSaveClicked();