2016-10-21 05:07:52 +00:00
|
|
|
import test from 'ava';
|
2019-03-17 12:21:07 +00:00
|
|
|
import pDefer from '.';
|
2016-10-21 05:07:52 +00:00
|
|
|
|
|
|
|
const fixture = Symbol('fixture');
|
|
|
|
|
|
|
|
function delay(ms) {
|
2019-03-17 12:21:07 +00:00
|
|
|
const deferred = pDefer();
|
2016-10-21 05:07:52 +00:00
|
|
|
setTimeout(deferred.resolve, ms, fixture);
|
|
|
|
return deferred.promise;
|
|
|
|
}
|
|
|
|
|
2019-03-17 12:21:07 +00:00
|
|
|
test('main', async t => {
|
2016-10-21 05:07:52 +00:00
|
|
|
t.is(await delay(50), fixture);
|
|
|
|
});
|