react-star-rating-input
Advanced tools
Comparing version 4.1.1 to 4.2.0
{ | ||
"name": "react-star-rating-input", | ||
"version": "4.1.1", | ||
"version": "4.2.0", | ||
"description": "React.js component for entering 0-5 stars", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,1 +18,13 @@ [![Build Status](https://travis-ci.org/ikr/react-star-rating-input.svg?branch=master)](https://travis-ci.org/ikr/react-star-rating-input) | ||
mentioned above. | ||
## Props | ||
Static layout | ||
* `size` -- how many stars to display. The default value is 5 | ||
* `showClear` -- hides the "Clear" link when `false`. The default value is `true` | ||
Interaction | ||
* `value` -- how many stars are selected | ||
* `onChange: function (value) {...}` -- your `value` change handler |
@@ -9,7 +9,8 @@ (function () { | ||
value: React.PropTypes.number, | ||
onChange: React.PropTypes.func | ||
onChange: React.PropTypes.func, | ||
showClear: React.PropTypes.bool | ||
}, | ||
getDefaultProps: function () { | ||
return {value: 0, size: 5}; | ||
return {value: 0, size: 5, showClear: true}; | ||
}, | ||
@@ -37,2 +38,3 @@ | ||
ref: 's0', | ||
style: this.props.showClear ? null : {display: 'none'}, | ||
@@ -39,0 +41,0 @@ onClick: function (e) { |
@@ -11,4 +11,9 @@ describe('StarRatingInput', function () { | ||
props = function (value, size, onChange) { | ||
return {value: value, size: size || 5, onChange: (onChange ? onChange : function () {})}; | ||
props = function (value, size, showClear, onChange) { | ||
return { | ||
value: value, | ||
size: size || 5, | ||
showClear: showClear, | ||
onChange: (onChange ? onChange : function () {}) | ||
}; | ||
}; | ||
@@ -25,5 +30,5 @@ | ||
describe('static markup', function () { | ||
var element = function (size) { | ||
var element = function (size, showClear) { | ||
return TestUtils.renderIntoDocument( | ||
React.createElement(StarRatingInput, props(0, size)) | ||
React.createElement(StarRatingInput, props(0, size, showClear)) | ||
).getDOMNode(); | ||
@@ -38,4 +43,9 @@ }; | ||
assert.strictEqual(bro.$('a.star-rating-clear', element()).text(), 'Clear'); | ||
assert.strictEqual(bro.$('a.star-rating-clear', element()).css('display'), ''); | ||
}); | ||
it('does not have "Clear" link when showClear is false', function () { | ||
assert.strictEqual(bro.$('a.star-rating-clear', element(5, false)).css('display'), 'none'); | ||
}); | ||
it('has the 5 star items as default', function () { | ||
@@ -105,3 +115,3 @@ assert.strictEqual(bro.$('.star-rating-star-container', element()).size(), 5); | ||
component = TestUtils.renderIntoDocument( | ||
React.createElement(StarRatingInput, props(1, 5, spy)) | ||
React.createElement(StarRatingInput, props(1, 5, false, spy)) | ||
); | ||
@@ -108,0 +118,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23809
275
30