chance-generators
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -89,3 +89,3 @@ /*global define*/ | ||
} else { | ||
return generator | ||
return mapGenerator | ||
} | ||
@@ -92,0 +92,0 @@ } |
{ | ||
"name": "chance-generators", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Random generators based on changejs", | ||
@@ -27,3 +27,3 @@ "main": "lib/chance-generators.js", | ||
"standard": "5.4.1", | ||
"unexpected": "10.5.1", | ||
"unexpected": "10.33.2", | ||
"unexpected-documentation-site-generator": "4.2.0", | ||
@@ -30,0 +30,0 @@ "unexpected-markdown": "1.6.1" |
@@ -78,2 +78,10 @@ /*global describe, it*/ | ||
}) | ||
it('keeps the map even when called out of order', () => { | ||
let generator = chance.integer({ min: -10, max: 10 }).map(v => '' + v) | ||
const val = generator() | ||
generator() | ||
generator = generator.shrink(val) | ||
expect(generator, 'when called', 'to be a string') | ||
}) | ||
}) | ||
@@ -255,2 +263,32 @@ }) | ||
describe('pickone', () => { | ||
describe('given an array', () => { | ||
it('returns a new generator picking a random element from the array', () => { | ||
const arr = [42, 'foo', { wat: 'taw' }] | ||
expect(chance.pickone(arr), 'when called', 'to be one of', arr) | ||
}) | ||
}) | ||
describe('given an array of generators', () => { | ||
it('returns a new generator picking a random elements from the array ' + | ||
'where the items are generated by the generators in the array', () => { | ||
const coordinates = chance.shape({ | ||
x: chance.integer, | ||
y: chance.integer | ||
}) | ||
for (var i = 0; i < 10; i += 1) { | ||
expect( | ||
chance.pickone([chance.integer, coordinates, chance.string, true]), | ||
'when called', | ||
expect.it('to be a number').or('to be a string').or('to be a boolean').or('to satisfy', { | ||
x: expect.it('to be a number'), | ||
y: expect.it('to be a number') | ||
}) | ||
) | ||
} | ||
}) | ||
}) | ||
}) | ||
describe('unique', () => { | ||
@@ -257,0 +295,0 @@ describe('given a generator and a number', () => { |
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
37192
752