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 ListEditorView from 'src/nfvo-components/listEditor/ListEditorView.jsx';
25 import ListEditorItemView from 'src/nfvo-components/listEditor/ListEditorItemView.jsx';
27 describe('listEditor Module Tests', function () {
30 it('list editor view should exist', () => {
31 expect(ListEditorView).toExist();
34 it('list editor item view should exist', () => {
35 expect(ListEditorItemView).toExist();
38 it('should render list and list item and call onEdit', done => {
39 let itemView = TestUtils.renderIntoDocument(
40 <ListEditorView title='some title'>
41 <ListEditorItemView onEdit={done}>
46 expect(itemView).toExist();
47 let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-sliders');
48 TestUtils.Simulate.click(sliderIcon);
51 it('should render list and list item and call onFilter', done => {
52 let itemView = TestUtils.renderIntoDocument(
53 <ListEditorView onFilter={()=>{done();}}>
59 expect(itemView).toExist();
60 let filterInput = TestUtils.findRenderedDOMComponentWithTag(itemView, 'input');
61 TestUtils.Simulate.change(filterInput);
64 it('should render READONLY list item and not call onEdit', done => {
65 let itemView = TestUtils.renderIntoDocument(
66 <ListEditorItemView onEdit={done} isReadOnlyMode={true}>
70 expect(itemView).toExist();
71 let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-sliders');
72 TestUtils.Simulate.click(sliderIcon);
75 it('should render list item and call onDelete', done => {
76 let itemView = TestUtils.renderIntoDocument(
77 <ListEditorItemView onDelete={done} isReadOnlyMode={false}>
81 expect(itemView).toExist();
82 let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-trash-o');
83 TestUtils.Simulate.click(sliderIcon);
86 it('should render READONLY list item and not call onDelete', () => {
87 let itemView = TestUtils.renderIntoDocument(
88 <ListEditorItemView onDelete={()=>{}} isReadOnlyMode={true}>
92 expect(itemView).toExist();
93 let sliderIcon = TestUtils.scryRenderedDOMComponentsWithClass(itemView, 'fa-trash-o');
94 expect(sliderIcon).toEqual(0);