2016-10-21 05:07:52 +00:00
|
|
|
import test from 'ava';
|
2021-04-09 05:21:28 +00:00
|
|
|
import pDefer from './index.js';
|
2016-10-21 05:07:52 +00:00
|
|
|
|
|
|
|
const fixture = Symbol('fixture');
|
|
|
|
|
2021-04-09 05:21:28 +00:00
|
|
|
function delay(milliseconds) {
|
2019-03-17 12:21:07 +00:00
|
|
|
const deferred = pDefer();
|
2021-04-09 05:21:28 +00:00
|
|
|
setTimeout(deferred.resolve, milliseconds, fixture);
|
2016-10-21 05:07:52 +00:00
|
|
|
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);
|
|
|
|
});
|