diff --git a/any.js b/any.js index a2caeff7..f0d619db 100644 --- a/any.js +++ b/any.js @@ -16,7 +16,7 @@ const DEFAULT_SIZE_RANGE = {max: 20, min: 1}; const integer = options => chance.natural(options); const float = options => chance.floating(options); const string = options => chance.string(options); -const word = options => chance.word(options); +const word = options => chance.word({syllables: 3, ...options}); const sentence = options => chance.sentence(options); const paragraph = options => chance.paragraph(options); const url = options => chance.url(options); @@ -29,7 +29,7 @@ function simpleObject() { const size = integer(DEFAULT_SIZE_RANGE); for (let i = 0; i < size; i += 1) { - object[word({syllables: 3})] = string(); + object[word()] = string(); } return object; diff --git a/test/unit/any-test.js b/test/unit/any-test.js index b69997ca..596ee135 100644 --- a/test/unit/any-test.js +++ b/test/unit/any-test.js @@ -48,11 +48,19 @@ suite('random data generator', () => { test('that a word is generated', () => { const word = chance.word(); - chanceStub.word.withArgs(options).returns(word); + chanceStub.word.withArgs({syllables: 3, ...options}).returns(word); assert.equal(any.word(options), word); }); + test('that syllables can be overridden', () => { + const word = chance.word(); + const expectedSyllables = any.integer(); + chanceStub.word.withArgs({syllables: expectedSyllables, ...options}).returns(word); + + assert.equal(any.word({syllables: expectedSyllables, ...options}), word); + }); + test('that a sentence is generated', () => { const sentence = chance.sentence(); chanceStub.sentence.withArgs(options).returns(sentence);