tapbundle/test/test.ts

33 lines
994 B
TypeScript
Raw Normal View History

2017-10-09 19:54:46 +00:00
import { tap, expect } from '../ts/index'
2017-04-23 09:10:13 +00:00
2017-04-28 07:49:57 +00:00
let test1 = tap.test('my first test -> expect true to be true', async () => {
2018-02-27 21:52:02 +00:00
return expect(true).to.be.true
2017-04-23 09:10:13 +00:00
})
2017-04-28 07:49:57 +00:00
let test2 = tap.test('my second test', async (tools) => {
await tools.delayFor(1000)
})
let test3 = tap.test('my third test -> test2 should take longer than test1 and endure at least 1000ms', async () => {
2018-02-27 21:52:02 +00:00
expect((await test1).hrtMeasurement.milliSeconds < (await test2).hrtMeasurement.milliSeconds).to.be.true
expect((await test2).hrtMeasurement.milliSeconds > 1000).to.be.true
2017-04-28 07:49:57 +00:00
})
let test4 = tap.skip.test('my 4th test -> should fail', async (tools) => {
2017-04-28 07:49:57 +00:00
tools.allowFailure()
2018-02-27 21:52:02 +00:00
expect(false).to.be.true
2017-04-28 07:49:57 +00:00
})
let test5 = tap.test('my 5th test -> should pass in about 500ms', async (tools) => {
tools.timeout(1000)
await tools.delayFor(500)
})
let test6 = tap.skip.test('my 6th test -> should fail after 1000ms', async (tools) => {
2017-04-28 07:49:57 +00:00
tools.allowFailure()
tools.timeout(1000)
await tools.delayFor(2000)
})
2017-04-23 09:10:13 +00:00
tap.start()