mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Add emitterEventPromise helper
This commit is contained in:
committed by
Katrina Uychaco
parent
cc2cbfbb0a
commit
6b92bd041a
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user