[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-ui / test / nfvo-components / listEditor / listEditor.test.js
index a3b098f..c1f823c 100644 (file)
@@ -1,25 +1,21 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
  */
 
-import expect from 'expect';
 import React from 'react';
+import {mount} from 'enzyme';
 import TestUtils from 'react-addons-test-utils';
 import ListEditorView from 'src/nfvo-components/listEditor/ListEditorView.jsx';
 import ListEditorItemView from 'src/nfvo-components/listEditor/ListEditorItemView.jsx';
@@ -28,11 +24,11 @@ describe('listEditor Module Tests', function () {
 
 
        it('list editor view should exist', () => {
-               expect(ListEditorView).toExist();
+               expect(ListEditorView).toBeTruthy();
        });
 
        it('list editor item view should exist', () => {
-               expect(ListEditorItemView).toExist();
+               expect(ListEditorItemView).toBeTruthy();
        });
 
        it('should render list and list item and call onEdit', done => {
@@ -43,22 +39,18 @@ describe('listEditor Module Tests', function () {
                                </ListEditorItemView>
                        </ListEditorView>
                );
-               expect(itemView).toExist();
-               let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-sliders');
+               expect(itemView).toBeTruthy();
+               let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'sliders');
                TestUtils.Simulate.click(sliderIcon);
        });
 
-       it('should render list and list item and call onFilter', done => {
-               let itemView = TestUtils.renderIntoDocument(
-                       <ListEditorView onFilter={()=>{done();}}>
-                               <ListEditorItemView>
-                                       <div></div>
-                               </ListEditorItemView>
-                       </ListEditorView>
+       it('should render list and list item and call onFilter', () => {
+               let itemView = mount(
+                       <ListEditorView onFilter={()=>{}} children={[(<ListEditorItemView key='id'/>)]} />
                );
-               expect(itemView).toExist();
-               let filterInput = TestUtils.findRenderedDOMComponentWithTag(itemView, 'input');
-               TestUtils.Simulate.change(filterInput);
+               expect(itemView).toBeTruthy();
+               let inputComponent = itemView.find('ExpandableInput');
+               expect(inputComponent.length).toBe(1);
        });
 
        it('should render READONLY list item and not call onEdit', done => {
@@ -67,8 +59,8 @@ describe('listEditor Module Tests', function () {
                                <div></div>
                        </ListEditorItemView>
                );
-               expect(itemView).toExist();
-               let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-sliders');
+               expect(itemView).toBeTruthy();
+               let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'sliders');
                TestUtils.Simulate.click(sliderIcon);
        });
 
@@ -78,8 +70,8 @@ describe('listEditor Module Tests', function () {
                                <div></div>
                        </ListEditorItemView>
                );
-               expect(itemView).toExist();
-               let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-trash-o');
+               expect(itemView).toBeTruthy();
+               let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'trash-o');
                TestUtils.Simulate.click(sliderIcon);
        });
 
@@ -89,8 +81,8 @@ describe('listEditor Module Tests', function () {
                                <div></div>
                        </ListEditorItemView>
                );
-               expect(itemView).toExist();
-               let sliderIcon = TestUtils.scryRenderedDOMComponentsWithClass(itemView, 'fa-trash-o');
-               expect(sliderIcon).toEqual(0);
+               expect(itemView).toBeTruthy();
+               let trashIcon = TestUtils.scryRenderedDOMComponentsWithClass(itemView, 'fa-trash-o');
+               expect(trashIcon).toEqual([]);
        });
 });