aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/nfvo-components/input/dualListBox
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-ui/test/nfvo-components/input/dualListBox')
-rw-r--r--openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js85
1 files changed, 50 insertions, 35 deletions
diff --git a/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js b/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js
index eaa06eedf4..c578178d35 100644
--- a/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js
+++ b/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js
@@ -1,24 +1,19 @@
-/*-
- * ============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 TestUtils from 'react-addons-test-utils';
import DualListboxView from 'nfvo-components/input/dualListbox/DualListboxView.jsx';
@@ -32,42 +27,62 @@ describe('dualListBox Module Tests', function () {
var renderer = TestUtils.createRenderer();
renderer.render(<DualListboxView onChange={()=>{}}/>);
var renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
it('should render with available list and 4 control buttons', () => {
var view = TestUtils.renderIntoDocument(<DualListboxView availableList={ITEMS} onChange={()=>{}}/>);
- expect(view).toExist();
+ expect(view).toBeTruthy();
var results = TestUtils.scryRenderedDOMComponentsWithClass(view, 'dual-list-option');
expect(results.length).toBe(4);
});
it('should add item to selected list', done => {
- const newItemValue = 'new item';
- let onChange = (value)=> {
- expect(value).toEqual(newItemValue);
+ const onChange = (values)=> {
+ expect(values).toEqual([ITEMS[2].id, ITEMS[0].id]);
done();
};
- var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]});
- expect(view).toExist();
- view.refs = {
- availableValues: {getValue(){return newItemValue;}}
- };
- view.addToSelectedList();
+ const document = TestUtils.renderIntoDocument(
+ <DualListboxView
+ availableList={ITEMS}
+ onChange={onChange}
+ selectedValuesList={[ITEMS[2].id]}/>);
+
+ const result = TestUtils.scryRenderedDOMComponentsWithTag(document, 'select');
+ const options = TestUtils.scryRenderedDOMComponentsWithTag(document, 'option');
+ const listBox = TestUtils.findRenderedComponentWithType(document, DualListboxView);
+ expect(result).toBeTruthy();
+ expect(options).toBeTruthy();
+ expect(listBox).toBeTruthy();
+
+ TestUtils.Simulate.change(result[0], {target: {selectedOptions: [options[0]]}});
+ expect(listBox.state.selectedValues).toEqual([ITEMS[0].id]);
+
+ listBox.addToSelectedList();
});
it('should remove item from selected list', done => {
- const selectedValuesList = ['a','b'];
- let onChange = (value)=> {
- expect(value).toEqual(selectedValuesList[1]);
+ const onChange = (values)=> {
+ expect(values).toEqual([ITEMS[0].id]);
done();
};
- var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList});
- expect(view).toExist();
- view.refs = {
- selectedValues: {getValue(){return ['a'];}}
- };
- view.removeFromSelectedList();
+ const document = TestUtils.renderIntoDocument(
+ <DualListboxView
+ availableList={ITEMS}
+ onChange={onChange}
+ selectedValuesList={[ITEMS[0].id, ITEMS[1].id]}/>);
+
+ const result = TestUtils.scryRenderedDOMComponentsWithTag(document, 'select');
+ const options = TestUtils.scryRenderedDOMComponentsWithTag(document, 'option');
+ const listBox = TestUtils.findRenderedComponentWithType(document, DualListboxView);
+ expect(result).toBeTruthy();
+ expect(options).toBeTruthy();
+ expect(listBox).toBeTruthy();
+
+ TestUtils.Simulate.change(result[1], {target: {selectedOptions: [options[2]]}});
+ expect(listBox.state.selectedValues).toEqual([ITEMS[1].id]);
+
+ listBox.removeFromSelectedList();
});
it('should add all items to selected list', done => {
@@ -76,7 +91,7 @@ describe('dualListBox Module Tests', function () {
done();
};
var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]});
- expect(view).toExist();
+ expect(view).toBeTruthy();
view.addAllToSelectedList();
});
@@ -86,7 +101,7 @@ describe('dualListBox Module Tests', function () {
done();
};
var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]});
- expect(view).toExist();
+ expect(view).toBeTruthy();
view.removeAllFromSelectedList();
});