You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
888 B
40 lines
888 B
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.")
|
|
})
|
|
})
|
|
|