2020-03-30 23:09:36 +00:00
|
|
|
import { expect } from 'chai';
|
|
|
|
|
2020-03-31 13:29:47 +00:00
|
|
|
import { defer, timeout } from '../../src/Async';
|
|
|
|
import { TimeoutError } from '../../src/error/TimeoutError';
|
2020-03-30 23:09:36 +00:00
|
|
|
|
2020-06-30 13:14:30 +00:00
|
|
|
describe('async utils', async () => {
|
|
|
|
describe('defer', async () => {
|
|
|
|
it('should resolve', async () => expect(defer(10, true)).to.eventually.equal(true));
|
2020-03-30 23:09:36 +00:00
|
|
|
});
|
|
|
|
|
2020-06-30 13:14:30 +00:00
|
|
|
describe('timeout', async () => {
|
|
|
|
it('should reject slow promises', async () => expect(timeout(10, defer(20))).to.eventually.be.rejectedWith(TimeoutError));
|
2020-03-30 23:09:36 +00:00
|
|
|
});
|
|
|
|
});
|