mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-23 07:36:12 +08:00
fix(change-mail): Fix performRemote never resolving if no threads or messages to process
This commit is contained in:
parent
029270bcae
commit
b7d829bfa1
2 changed files with 14 additions and 2 deletions
|
@ -198,6 +198,15 @@ describe "ChangeMailTask", ->
|
|||
expect(@task.performRequests).toHaveBeenCalledWith(Message, @task.messages)
|
||||
expect(@task.performRequests.callCount).toBe(1)
|
||||
|
||||
describe "if somehow there are no threads or messages", ->
|
||||
it "should resolve", ->
|
||||
@task = new ChangeMailTask()
|
||||
@task.threads = []
|
||||
@task.messages = []
|
||||
waitsForPromise =>
|
||||
@task.performRemote().then (code) =>
|
||||
expect(code).toEqual(Task.Status.Finished)
|
||||
|
||||
describe "if performRequests resolves", ->
|
||||
it "should resolve with Task.Status.Finished", ->
|
||||
@task = new ChangeMailTask()
|
||||
|
|
|
@ -38,8 +38,11 @@ mapLimit = (input, numberInParallel, fn) ->
|
|||
outputError = err
|
||||
reject(outputError)
|
||||
|
||||
numberInParallel = Math.min(numberInParallel, input.length)
|
||||
startNext() for n in [0...numberInParallel]
|
||||
if input.length > 0
|
||||
numberInParallel = Math.min(numberInParallel, input.length)
|
||||
startNext() for n in [0...numberInParallel]
|
||||
else
|
||||
resolve([])
|
||||
|
||||
# The ChangeMailTask is a base class for all tasks that modify sets of threads or
|
||||
# messages. Subclasses implement `_changesToModel` and `_requestBodyForModel` to
|
||||
|
|
Loading…
Reference in a new issue