Skip to content

Instantly share code, notes, and snippets.

@jasdev
Created April 10, 2021 19:55
Show Gist options
  • Save jasdev/b4b20ef46af35669961f214f26a7fe0d to your computer and use it in GitHub Desktop.
Save jasdev/b4b20ef46af35669961f214f26a7fe0d to your computer and use it in GitHub Desktop.
Adding a lone, upstream completion case to CombineExt’s WithLatestFromTests.swift
final class WithLatestFromTests: XCTestCase {
// …
func testWithLatestFromCompletion() {
let subject1 = PassthroughSubject<Int, Never>()
let subject2 = PassthroughSubject<String, Never>()
var results = [String]()
var completed = false
subscription = subject1
.withLatestFrom(subject2)
.sink(
receiveCompletion: { _ in completed = true },
receiveValue: { results.append($0) }
)
subject1.send(completion: .finished)
XCTAssertTrue(completed) // ❌ “`XCTAssertTrue` failed.”
XCTAssertTrue(results.isEmpty)
}
// Tests for other arities.
func testWithLatestFrom2Completion() {}
func testWithLatestFrom3Completion() {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment