Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Word generation now defaults to generating 3 syllables #230

Merged
merged 4 commits into from
Jul 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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