mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
Convert text-editor-component-spec to Babel for async/await
It's much easier to reason about async/await than Jasmine's built-in queuing system, and using them made it easier to debug flaky async tests.
This commit is contained in:
28
spec/async-spec-helpers.coffee
Normal file
28
spec/async-spec-helpers.coffee
Normal file
@@ -0,0 +1,28 @@
|
||||
exports.beforeEach = (fn) ->
|
||||
global.beforeEach ->
|
||||
result = fn()
|
||||
if result instanceof Promise
|
||||
waitsForPromise(-> result)
|
||||
|
||||
exports.afterEach = (fn) ->
|
||||
global.afterEach ->
|
||||
result = fn()
|
||||
if result instanceof Promise
|
||||
waitsForPromise(-> result)
|
||||
|
||||
['it', 'fit', 'ffit', 'fffit'].forEach (name) ->
|
||||
exports[name] = (description, fn) ->
|
||||
global[name] description, ->
|
||||
result = fn()
|
||||
if result instanceof Promise
|
||||
waitsForPromise(-> result)
|
||||
|
||||
waitsForPromise = (fn) ->
|
||||
promise = fn()
|
||||
waitsFor 10000, (done) ->
|
||||
promise.then(
|
||||
done,
|
||||
(error) ->
|
||||
jasmine.getEnv().currentSpec.fail(error)
|
||||
done()
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
4735
spec/text-editor-component-spec.js
Normal file
4735
spec/text-editor-component-spec.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1076,7 +1076,7 @@ class DisplayBuffer extends Model
|
||||
|
||||
unless @didUpdateDecorationsEventScheduled
|
||||
@didUpdateDecorationsEventScheduled = true
|
||||
process.nextTick =>
|
||||
global.setImmediate =>
|
||||
@didUpdateDecorationsEventScheduled = false
|
||||
@emitter.emit 'did-update-decorations'
|
||||
|
||||
|
||||
@@ -224,8 +224,10 @@ class ViewRegistry
|
||||
# process updates requested as a result of reads
|
||||
writer() while writer = @documentWriters.shift()
|
||||
|
||||
resolveNextUpdatePromise = @resolveNextUpdatePromise
|
||||
@nextUpdatePromise = null
|
||||
@resolveNextUpdatePromise?()
|
||||
@resolveNextUpdatePromise = null
|
||||
resolveNextUpdatePromise?()
|
||||
|
||||
startPollingDocument: ->
|
||||
window.addEventListener('resize', @requestDocumentPoll)
|
||||
|
||||
Reference in New Issue
Block a user