react-star-rating-input
Advanced tools
Comparing version 4.0.0 to 4.1.0
{ | ||
"name": "react-star-rating-input", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "React.js component for entering 0-5 stars", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,3 +13,3 @@ (function () { | ||
getDefaultProps: function () { | ||
return {value: 0}; | ||
return {value: 0, size: 5}; | ||
}, | ||
@@ -48,5 +48,8 @@ | ||
starItems: function () { | ||
return [1, 2, 3, 4, 5].map(function (value) { | ||
return this.starItem(value, this.anchorMode(value)); | ||
}.bind(this)); | ||
var stars = [], | ||
i; | ||
for (i = 1; i <= this.props.size; i += 1) { | ||
stars.push(this.starItem(i, this.anchorMode(i))); | ||
} | ||
return stars; | ||
}, | ||
@@ -53,0 +56,0 @@ |
@@ -11,4 +11,4 @@ describe('StarRatingInput', function () { | ||
props = function (value, onChange) { | ||
return {value: value, onChange: (onChange ? onChange : function () {})}; | ||
props = function (value, size, onChange) { | ||
return {value: value, size: size || 5, onChange: (onChange ? onChange : function () {})}; | ||
}; | ||
@@ -25,21 +25,23 @@ | ||
describe('static markup', function () { | ||
var element; | ||
beforeEach(function () { | ||
element = TestUtils.renderIntoDocument( | ||
React.createElement(StarRatingInput, props(0)) | ||
var element = function (size) { | ||
return TestUtils.renderIntoDocument( | ||
React.createElement(StarRatingInput, props(0, size)) | ||
).getDOMNode(); | ||
}); | ||
}; | ||
it('has the root element\'s class assigned', function () { | ||
assert(bro.$(element).hasClass('star-rating-input')); | ||
assert(bro.$(element()).hasClass('star-rating-input')); | ||
}); | ||
it('has the "Clear" link', function () { | ||
assert.strictEqual(bro.$('a.star-rating-clear', element).text(), 'Clear'); | ||
assert.strictEqual(bro.$('a.star-rating-clear', element()).text(), 'Clear'); | ||
}); | ||
it('has the 5 star items', function () { | ||
assert.strictEqual(bro.$('.star-rating-star-container', element).size(), 5); | ||
it('has the 5 star items as default', function () { | ||
assert.strictEqual(bro.$('.star-rating-star-container', element()).size(), 5); | ||
}); | ||
it('has the N star items', function () { | ||
assert.strictEqual(bro.$('.star-rating-star-container', element(10)).size(), 10); | ||
}); | ||
}); | ||
@@ -102,3 +104,3 @@ | ||
component = TestUtils.renderIntoDocument( | ||
React.createElement(StarRatingInput, props(1, spy)) | ||
React.createElement(StarRatingInput, props(1, 5, spy)) | ||
); | ||
@@ -105,0 +107,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
22901
263