mirror of
https://github.com/atom/atom.git
synced 2026-01-22 13:28:01 -05:00
In workspace-spec.coffee, updated FakeSearch to match the spec, which
helped uncover a bug.
This commit is contained in:
@@ -954,7 +954,9 @@ describe "Workspace", ->
|
||||
@promise.then.apply(@promise, args)
|
||||
cancel: ->
|
||||
@cancelled = true
|
||||
@hoistedReject()
|
||||
# According to the spec for a DirectorySearcher, invoking `cancel()` should
|
||||
# resolve the thenable rather than reject it.
|
||||
@hoistedResolve()
|
||||
|
||||
beforeEach ->
|
||||
fakeSearch = null
|
||||
|
||||
@@ -873,18 +873,16 @@ class Workspace extends Model
|
||||
isCancelled = false
|
||||
cancellablePromise = new Promise (resolve, reject) ->
|
||||
onSuccess = ->
|
||||
resolve(null)
|
||||
onFailure = ->
|
||||
if isCancelled
|
||||
resolve('cancelled')
|
||||
else
|
||||
reject()
|
||||
searchPromise.then(onSuccess, onFailure)
|
||||
resolve(null)
|
||||
searchPromise.then(onSuccess, reject)
|
||||
cancellablePromise.cancel = ->
|
||||
isCancelled = true
|
||||
# Note that cancelling all (or actually, any) of the members of allSearches
|
||||
# will cause searchPromise to reject, which will cause cancellablePromise to resolve
|
||||
# in the desired way.
|
||||
# Note that cancelling all of the members of allSearches will cause all of the searches
|
||||
# to resolve, which causes searchPromise to resolve, which is ultimately what causes
|
||||
# cancellablePromise to resolve.
|
||||
promise.cancel() for promise in allSearches
|
||||
|
||||
# Although this method claims to return a `Promise`, the `ResultsPaneView.onSearch()`
|
||||
|
||||
Reference in New Issue
Block a user