aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarak <[email protected]>2015-07-04 23:42:43 -0700
committerMarak <[email protected]>2015-07-04 23:42:43 -0700
commit2907c27ca9cf3657188470094a689decda3df65a (patch)
tree9ea4717ea4196a86582474e48c4094f68cb10c7d
parent846e3812575b700c3d930463a3bf47c8fd968097 (diff)
downloadfaker-2907c27ca9cf3657188470094a689decda3df65a.tar.xz
faker-2907c27ca9cf3657188470094a689decda3df65a.zip
[api] [fix] Remove tabs from paragraph generation. Make paragraph separator configurable. Closes #223
-rw-r--r--lib/lorem.js19
-rw-r--r--test/lorem.unit.js4
2 files changed, 13 insertions, 10 deletions
diff --git a/lib/lorem.js b/lib/lorem.js
index aaea46f9..eb4d72d5 100644
--- a/lib/lorem.js
+++ b/lib/lorem.js
@@ -21,7 +21,7 @@ var lorem = {
if (typeof sentenceCount == 'undefined') { sentenceCount = 3; }
var sentences = [];
for (sentenceCount; sentenceCount > 0; sentenceCount--) {
- sentences.push(faker.lorem.sentence());
+ sentences.push(faker.lorem.sentence());
}
return sentences.join("\n");
},
@@ -31,13 +31,16 @@ var lorem = {
return faker.lorem.sentences(sentenceCount + faker.random.number(3));
},
- paragraphs: function (paragraphCount) {
- if (typeof paragraphCount == 'undefined') { paragraphCount = 3; }
- var paragraphs = [];
- for (paragraphCount; paragraphCount > 0; paragraphCount--) {
- paragraphs.push(faker.lorem.paragraph());
- }
- return paragraphs.join("\n \r\t");
+ paragraphs: function (paragraphCount, separator) {
+ if (typeof separator === "undefined") {
+ separator = "\n \r";
+ }
+ if (typeof paragraphCount == 'undefined') { paragraphCount = 3; }
+ var paragraphs = [];
+ for (paragraphCount; paragraphCount > 0; paragraphCount--) {
+ paragraphs.push(faker.lorem.paragraph());
+ }
+ return paragraphs.join(separator);
}
};
diff --git a/test/lorem.unit.js b/test/lorem.unit.js
index 3b554d47..4fecb4ba 100644
--- a/test/lorem.unit.js
+++ b/test/lorem.unit.js
@@ -158,7 +158,7 @@ describe("lorem.js", function () {
var paragraphs = faker.lorem.paragraphs();
assert.ok(typeof paragraphs === 'string');
- var parts = paragraphs.split('\n \r\t');
+ var parts = paragraphs.split('\n \r');
assert.equal(parts.length, 3);
assert.ok(faker.lorem.paragraph.calledThrice);
@@ -172,7 +172,7 @@ describe("lorem.js", function () {
var paragraphs = faker.lorem.paragraphs(5);
assert.ok(typeof paragraphs === 'string');
- var parts = paragraphs.split('\n \r\t');
+ var parts = paragraphs.split('\n \r');
assert.equal(parts.length, 5);
faker.lorem.paragraph.restore();