In workspace-spec.coffee, updated FakeSearch to match the spec, which

helped uncover a bug.
This commit is contained in:
Michael Bolin
2015-06-10 13:25:24 +01:00
parent 3c44bc06f4
commit ad46b37cfe
2 changed files with 8 additions and 8 deletions

View File

@@ -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

View File

@@ -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()`