implement random time

This commit is contained in:
2017-10-09 11:33:59 +02:00
parent 645a1ca111
commit 62a5975fb3
4 changed files with 44 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import { expect, tap } from 'tapbundle'
import * as smartdelay from '../dist/index'
import * as smartdelay from '../ts/index'
tap.test('.delayFor should delay async', async (tools) => {
tools.timeout(5000)
@ -14,6 +14,18 @@ tap.test('.delayFor should delay async', async (tools) => {
})
})
tap.test('.delayForRandpm should delay async for a random time period', async (tools) => {
tools.timeout(5000)
let timePassed = false
setTimeout(() => {
timePassed = true
}, 3000)
await smartdelay.delayForRandom(3000,4900).then(async () => {
// tslint:disable-next-line:no-unused-expression
expect(timePassed).to.be.true
})
})
tap.test('.delayFor should pass on a type', async (tools) => {
tools.timeout(5000)
let timePassed = false