Add emitterEventPromise helper

This commit is contained in:
Michelle Tilley
2017-03-23 23:37:06 -07:00
committed by Katrina Uychaco
parent cc2cbfbb0a
commit 6b92bd041a

View File

@@ -1,5 +1,7 @@
/** @babel */
import until from 'test-until'
export function beforeEach (fn) {
global.beforeEach(function () {
const result = fn()
@@ -60,3 +62,12 @@ function waitsForPromise (fn) {
})
})
}
export function emitterEventPromise (emitter, event, timeout = 5000) {
let called = false
emitter.once(event, () => {
called = true
// disposable.dispose()
})
return until(`${event} is emitted`, () => called, timeout)
}