Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Tests/AsyncSubjets/StreamedTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import AsyncExtensions
import Combine
import XCTest

final class StreamedTests: XCTestCase {
Expand Down
6 changes: 4 additions & 2 deletions Tests/Creators/AsyncLazySequenceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class AsyncLazySequenceTests: XCTestCase {
XCTAssertEqual(receivedResult, sequence)
}

func test_AsyncLazySequence_returns_an_asyncSequence_that_finishes_when_task_is_cancelled() {
func test_AsyncLazySequence_returns_an_asyncSequence_that_finishes_when_task_is_cancelled() async {
let canCancelExpectation = expectation(description: "The first element has been emitted")
let hasCancelExceptation = expectation(description: "The task has been cancelled")

Expand All @@ -41,10 +41,12 @@ final class AsyncLazySequenceTests: XCTestCase {
XCTAssertEqual(firstElement!, 0) // the AsyncSequence is cancelled having only emitted the first element
}

wait(for: [canCancelExpectation], timeout: 5) // one element has been emitted, we can cancel the task
await fulfillment(of: [canCancelExpectation], timeout: 5) // one element has been emitted, we can cancel the task

task.cancel()

hasCancelExceptation.fulfill() // we can release the lock in the for loop

await task.value
}
}