SB-6.1-PRE
This commit is contained in:
1 parent
690169a409
commit
358a25f522
3760 files changed
+300059
-36
No files matched your search
+40
@@ -0,0 +1,40 @@
|
||||
import test from 'ava'
|
||||
import Chance from '../chance.js'
|
||||
import _ from 'lodash'
|
||||
|
||||
const chance = new Chance()
|
||||
|
||||
const timeout = (seconds) => {
|
||||
new Promise((resolve, reject) => {
|
||||
setTimeout(() => resolve(), seconds)
|
||||
})
|
||||
}
|
||||
|
||||
//chance.animal()
|
||||
|
||||
test('returns an animal', t => {
|
||||
_.times(1000, () => {
|
||||
let animal = chance.animal({
|
||||
type: "desert"
|
||||
})
|
||||
t.true(_.isString(animal))
|
||||
t.true(animal.length >= 2)
|
||||
})
|
||||
})
|
||||
|
||||
test('returns an animal even if type is not specified', t => {
|
||||
_.times(1000, () => {
|
||||
let animal = chance.animal()
|
||||
t.true(_.isString(animal))
|
||||
t.true(animal.length >= 2)
|
||||
})
|
||||
})
|
||||
|
||||
test('throws an error if the type is not part of the animals object', t => {
|
||||
_.times(1000, () => {
|
||||
const fn = () => chance.animal({
|
||||
type: "banana"
|
||||
})
|
||||
t.throws(fn, "Please pick from desert, ocean, grassland, forest, zoo, pets, farm.")
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user