Skip to content

Commit

Permalink
Refactor many_concurrent_tasks test
Browse files Browse the repository at this point in the history
  • Loading branch information
Montak Oleg committed Jan 22, 2018
1 parent ecf382c commit c9257b0
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions WhenTests/Shared/FunctionsSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,7 @@ class FunctionsSpec: QuickSpec {
context("with many concurrent tasks") {
it("resolves the promise") {
let promises: [Promise<Int>] = (0..<10000).map { _ in
let promise = Promise<Int>(queue: DispatchQueue.global(), { resolve in
// +1 needed to avoid https://github.com/vadymmarkov/When/issues/27
DispatchQueue.global().asyncAfter(deadline: DispatchTime.now() + 1) {
resolve(1)
}
})
return promise
return Promise<Int>(queue: DispatchQueue.global())
}

let doneExpectation = self.expectation(description: "Done expectation")
Expand All @@ -74,7 +68,11 @@ class FunctionsSpec: QuickSpec {
doneExpectation.fulfill()
})

self.waitForExpectations(timeout: 2.0, handler:nil)
promises.forEach {
$0.resolve(1)
}

self.waitForExpectations(timeout: 5.0, handler:nil)
}
}
}
Expand Down

0 comments on commit c9257b0

Please sign in to comment.