Skip to content

Commit

Permalink
Merge pull request #230 from richardson-trevor/default-word
Browse files Browse the repository at this point in the history
Word generation now defaults to generating 3 syllables
  • Loading branch information
travi authored Jul 28, 2017
2 parents 677f5d8 + 382ec8a commit 1da4cc0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"presets": [
"es2015-node"
"es2015-node",
"stage-3"
],
"plugins": [
"babel-plugin-transform-exponentiation-operator"
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
4 changes: 2 additions & 2 deletions any.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
"chance"
],
"author": "Matt Travi <npm@travi.org> (https://matt.travi.org/)",
"contributors": [
{
"name": "Trevor Richardson",
"email": "tr@trevorrichardson.me",
"url": "https://twitter.com/intelxdesign"
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/travi/any/issues"
Expand All @@ -48,6 +55,7 @@
"babel-plugin-transform-exponentiation-operator": "6.24.1",
"babel-preset-es2015-node": "6.1.1",
"babel-preset-es2015-rollup": "3.0.0",
"babel-preset-stage-3": "6.24.1",
"babel-register": "6.24.1",
"chai": "4.1.0",
"coveralls": "2.13.1",
Expand Down
5 changes: 4 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ export default {
babel({
babelrc: false,
exclude: ['./node_modules/**'],
presets: ['es2015-rollup'],
presets: [
'es2015-rollup',
'stage-3'
],
plugins: ['babel-plugin-transform-exponentiation-operator']
})
],
Expand Down
10 changes: 9 additions & 1 deletion test/unit/any-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1da4cc0

Please sign in to comment.