react-select-search
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -10,17 +10,25 @@ jest.dontMock('../index'); | ||
describe('SelectSearch', () => { | ||
describe('SelectWithSearch', () => { | ||
const selectSearch = TestUtils.renderIntoDocument( | ||
<SelectSearch name="country" options={[{name: 'Sweden', value: 'SE'}, {name: 'Italy', value: 'IT'}]} value="SE" /> | ||
); | ||
it('has select options', () => { | ||
var selectSearch = TestUtils.renderIntoDocument( | ||
<SelectSearch name="country" options={[{name: 'Sweden', value: 'SE'}, {name: 'Italy', value: 'IT'}]} value="SE" /> | ||
), selectSearchNode; | ||
var selectSearchNode = ReactDOM.findDOMNode(selectSearch); | ||
selectSearchNode = ReactDOM.findDOMNode(selectSearch); | ||
TestUtils.Simulate.focus(selectSearchNode.querySelector('.select-search-box__search')); | ||
TestUtils.Simulate.click(selectSearchNode.querySelector('.select-search-box__search')); | ||
expect(selectSearchNode.querySelectorAll('.select-search-box__option').length).toEqual(2); | ||
}); | ||
it('empties search field on focus', () => { | ||
var selectSearchNode = ReactDOM.findDOMNode(selectSearch), | ||
searchField = selectSearchNode.querySelector('.select-search-box__search'); | ||
TestUtils.Simulate.focus(searchField); | ||
expect(searchField.value.length).toEqual(0); | ||
}); | ||
}); |
@@ -26,3 +26,20 @@ 'use strict'; | ||
var displayName = 'SelectSearch'; | ||
var propTypes = {}; | ||
var propTypes = { | ||
options: _react2.default.PropTypes.array.isRequired, | ||
className: _react2.default.PropTypes.string.isRequired, | ||
search: _react2.default.PropTypes.bool.isRequired, | ||
value: _react2.default.PropTypes.string, | ||
placeholder: _react2.default.PropTypes.string, | ||
multiple: _react2.default.PropTypes.bool.isRequired, | ||
height: _react2.default.PropTypes.number, | ||
name: _react2.default.PropTypes.string, | ||
fuse: _react2.default.PropTypes.object.isRequired, | ||
valueChanged: _react2.default.PropTypes.func.isRequired, | ||
optionSelected: _react2.default.PropTypes.func.isRequired, | ||
onMount: _react2.default.PropTypes.func.isRequired, | ||
onBlur: _react2.default.PropTypes.func.isRequired, | ||
onFocus: _react2.default.PropTypes.func.isRequired, | ||
renderOption: _react2.default.PropTypes.func.isRequired | ||
}; | ||
var defaultProps = { | ||
@@ -68,4 +85,4 @@ options: [], | ||
search: null, | ||
value: !_this.props.value && _this.props.multiple ? [] : _this.props.value, | ||
options: _this.props.options | ||
value: !props.value && props.multiple ? [] : props.value, | ||
options: props.options | ||
}; | ||
@@ -72,0 +89,0 @@ |
24
index.js
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -8,3 +7,20 @@ | ||
const displayName = 'SelectSearch'; | ||
const propTypes = {}; | ||
const propTypes = { | ||
options: React.PropTypes.array.isRequired, | ||
className: React.PropTypes.string.isRequired, | ||
search: React.PropTypes.bool.isRequired, | ||
value: React.PropTypes.string, | ||
placeholder: React.PropTypes.string, | ||
multiple: React.PropTypes.bool.isRequired, | ||
height: React.PropTypes.number, | ||
name: React.PropTypes.string, | ||
fuse: React.PropTypes.object.isRequired, | ||
valueChanged: React.PropTypes.func.isRequired, | ||
optionSelected: React.PropTypes.func.isRequired, | ||
onMount: React.PropTypes.func.isRequired, | ||
onBlur: React.PropTypes.func.isRequired, | ||
onFocus: React.PropTypes.func.isRequired, | ||
renderOption: React.PropTypes.func.isRequired | ||
}; | ||
const defaultProps = { | ||
@@ -47,4 +63,4 @@ options: [], | ||
search: null, | ||
value: (!this.props.value && this.props.multiple) ? [] : this.props.value, | ||
options: this.props.options | ||
value: (!props.value && props.multiple) ? [] : props.value, | ||
options: props.options | ||
}; | ||
@@ -51,0 +67,0 @@ |
{ | ||
"name": "react-select-search", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "React powered selectbox with filter", | ||
@@ -5,0 +5,0 @@ "main": "dist/es5.js", |
48128
989