2 * Copyright © 2016-2017 European Support Limited
4 * 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
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 import React from 'react';
18 import {mount} from 'enzyme';
19 import TestUtils from 'react-addons-test-utils';
20 import ListEditorView from 'src/nfvo-components/listEditor/ListEditorView.jsx';
21 import ListEditorItemView from 'src/nfvo-components/listEditor/ListEditorItemView.jsx';
23 describe('listEditor Module Tests', function () {
26 it('list editor view should exist', () => {
27 expect(ListEditorView).toBeTruthy();
30 it('list editor item view should exist', () => {
31 expect(ListEditorItemView).toBeTruthy();
34 it('should render list and list item and call onEdit', done => {
35 let itemView = TestUtils.renderIntoDocument(
36 <ListEditorView title='some title'>
37 <ListEditorItemView onEdit={done}>
42 expect(itemView).toBeTruthy();
43 let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, '__sliders');
44 TestUtils.Simulate.click(sliderIcon);
47 it('should render list and list item and call onFilter', () => {
49 <ListEditorView onFilter={()=>{}} children={[(<ListEditorItemView key='id'/>)]} />
51 expect(itemView).toBeTruthy();
52 let inputComponent = itemView.find('ExpandableInput');
53 expect(inputComponent.length).toBe(1);
56 it('should render READONLY list item and not call onEdit', done => {
57 let itemView = TestUtils.renderIntoDocument(
58 <ListEditorItemView onEdit={done} isReadOnlyMode={true}>
62 expect(itemView).toBeTruthy();
63 let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, '__sliders');
64 TestUtils.Simulate.click(sliderIcon);
67 it('should render list item and call onDelete', done => {
68 let itemView = TestUtils.renderIntoDocument(
69 <ListEditorItemView onDelete={done} isReadOnlyMode={false}>
73 expect(itemView).toBeTruthy();
74 let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, '__trashO');
75 TestUtils.Simulate.click(sliderIcon);
78 it('should render READONLY list item and not call onDelete', () => {
79 let itemView = TestUtils.renderIntoDocument(
80 <ListEditorItemView onDelete={()=>{}} isReadOnlyMode={true}>
84 expect(itemView).toBeTruthy();
85 let trashIcon = TestUtils.scryRenderedDOMComponentsWithClass(itemView, '__trashOq');
86 expect(trashIcon).toEqual([]);