p-defer/test.js

15 lines
270 B
JavaScript
Raw Normal View History

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