react-lorem-component
Advanced tools
Comparing version 0.4.0 to 0.5.0
18
index.js
@@ -12,3 +12,6 @@ "use strict"; | ||
getDefaultProps: function() { | ||
return { count: 5, seed: 0 }; | ||
return { | ||
mode: "paragraphs", count: 5, | ||
seed: 0, ordered: false | ||
}; | ||
}, | ||
@@ -26,5 +29,16 @@ | ||
var html = loremIpsum(options); | ||
var wrapper = React.DOM.div; | ||
if (this.props.mode === "list") { | ||
html = html.replace(/<p>(.*?)<\/p>/g, "<li>$1</li>"); | ||
if (this.props.ordered === true) { | ||
wrapper = React.DOM.ol; | ||
} else { | ||
wrapper = React.DOM.ul; | ||
} | ||
} | ||
return this.transferPropsTo( | ||
React.DOM.div({ dangerouslySetInnerHTML: { __html: html } }) | ||
wrapper({ dangerouslySetInnerHTML: { __html: html } }) | ||
); | ||
@@ -31,0 +45,0 @@ } |
{ | ||
"name": "react-lorem-component", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "A component for React that renders paragraph tags full of lorem ipsum text", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
56
spec.js
@@ -1,20 +0,48 @@ | ||
var assert = require("assert"); | ||
var React = require("react"); | ||
var LoremIpsum = require("./index"); | ||
var assert = require('assert'); | ||
var React = require('react'); | ||
var LoremIpsum = require('./index'); | ||
describe("react-lorem-component", function() { | ||
it("renders lorem ipsum text", function() { | ||
var component = LoremIpsum({ | ||
count: 2, | ||
words: ["foo"], | ||
sentenceLowerBound: 3, | ||
sentenceUpperBound: 3, | ||
paragraphLowerBound: 2, | ||
paragraphUpperBound: 2 | ||
describe('react-lorem-component', function() { | ||
it('transfers properties', function() { | ||
React.renderComponentToString(LoremIpsum({ className: "lorem-ipsum" }), function(markup) { | ||
assert(/^<div [^>]*?class="lorem-ipsum"/.test(markup)); | ||
}); | ||
}); | ||
React.renderComponentToString(component, function(markup) { | ||
assert(/<p>Foo foo foo. Foo foo foo.<\/p><p>Foo foo foo. Foo foo foo.<\/p>/.test(markup)); | ||
describe('by default', function() { | ||
it('renders lorem ipsum paragraphs wrapped in a DIV tag', function() { | ||
var component = LoremIpsum({ | ||
count: 2, | ||
words: ['foo'], | ||
sentenceLowerBound: 3, | ||
sentenceUpperBound: 3, | ||
paragraphLowerBound: 2, | ||
paragraphUpperBound: 2 | ||
}); | ||
React.renderComponentToString(component, function(markup) { | ||
assert(/^<div [^>]+><p>Foo foo foo. Foo foo foo.<\/p><p>Foo foo foo. Foo foo foo.<\/p><\/div>$/.test(markup)); | ||
}); | ||
}); | ||
}); | ||
describe('with `mode` property set to "list"', function() { | ||
it('renders lorem ipsum list items wrapped in an UL tag', function() { | ||
var component = LoremIpsum({ count: 2, mode: 'list' }); | ||
React.renderComponentToString(component, function(markup) { | ||
assert(/^<ul [^>]+><li>.+<\/li><\/ul>$/.test(markup)); | ||
}); | ||
}); | ||
describe('and with `ordered` property set to `true`', function() { | ||
it('renders lorem ipsum list items wrapped in an OL tag', function() { | ||
var component = LoremIpsum({ count: 2, mode: 'list', ordered: true }); | ||
React.renderComponentToString(component, function(markup) { | ||
assert(/^<ol [^>]+><li>.+<\/li><\/ol>$/.test(markup)); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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
6192
77