diff --git a/Sources/PublisherExpectations/PublisherExpectations.swift b/Sources/PublisherExpectations/PublisherExpectations.swift index e9f1801..8b9f437 100644 --- a/Sources/PublisherExpectations/PublisherExpectations.swift +++ b/Sources/PublisherExpectations/PublisherExpectations.swift @@ -1,5 +1,5 @@ // -// File.swift +// PublisherExpectations.swift // // // Created by Joan Duat on 16/2/23. @@ -13,9 +13,10 @@ public final class PublisherValueExpectation: XCTestExpectation { private var cancellable: AnyCancellable? /// Initializes a PublisherValueExpectation that is fulfilled when the publisher emits a value that matches the condition. - public init(_ publisher: P, - condition: @escaping (P.Output) -> Bool, - description expectationDescription: String? = nil) + public init( + _ publisher: P, + condition: @escaping (P.Output) -> Bool, + description expectationDescription: String? = nil) { let description = expectationDescription ?? "Publisher expected to emit a value that matches the condition." super.init(description: description) @@ -28,8 +29,10 @@ public final class PublisherValueExpectation: XCTestExpectation { } /// Initializes a PublisherValueExpectation that is fulfilled when the publisher emits the expected value. - public convenience init(_ publisher: P, expectedValue: P.Output, - description expectationDescription: String? = nil) where P.Output: Equatable + public convenience init( + _ publisher: P, expectedValue: P.Output, + description expectationDescription: String? = nil + ) where P.Output: Equatable { let description = expectationDescription ?? "Publisher expected to emit the value '\(expectedValue)'" self.init(publisher, condition: { $0 == expectedValue }, description: description) @@ -42,8 +45,9 @@ public final class PublisherFinishedExpectation: XCTestExpectation private var isConditionFulfilled = false /// Initializes a PublisherFinishedExpectation that is fulfilled when the publisher completes successfully. - public init(_ publisher: P, - description expectationDescription: String = "Publisher expected to finish") + public init( + _ publisher: P, + description expectationDescription: String = "Publisher expected to finish") { super.init(description: expectationDescription) cancellable = publisher.sink(receiveCompletion: { [weak self] completion in @@ -57,9 +61,10 @@ public final class PublisherFinishedExpectation: XCTestExpectation } /// Initializes a PublisherFinishedExpectation that is fulfilled when the publisher completes successfully after emitting a value that matches a certain condition. - public init(_ publisher: P, - condition: @escaping (P.Output) -> Bool, - description expectationDescription: String? = nil) + public init( + _ publisher: P, + condition: @escaping (P.Output) -> Bool, + description expectationDescription: String? = nil) { let description = expectationDescription ?? "Publisher expected to finish after matching the condition." super.init(description: description) @@ -81,8 +86,10 @@ public final class PublisherFinishedExpectation: XCTestExpectation } /// Initializes a PublisherFinishedExpectation that is fulfilled when the publisher completes successfully after emitting a certain value. - public convenience init(_ publisher: P, expectedValue: P.Output, - description expectationDescription: String? = nil) where P.Output: Equatable + public convenience init( + _ publisher: P, expectedValue: P.Output, + description expectationDescription: String? = nil + ) where P.Output: Equatable { let description = expectationDescription ?? "Publisher expected to finish after emitting the value '\(expectedValue)'" self.init(publisher, condition: { $0 == expectedValue }, description: description) @@ -94,9 +101,10 @@ public final class PublisherFailureExpectation: XCTestExpectation private var cancellable: AnyCancellable? /// Initializes a PublisherFailureExpectation that is fulfilled when the publisher fails with an error that matches the condition. - public init(_ publisher: P, - condition: @escaping (P.Failure) -> Bool, - description expectationDescription: String = "Failure was expected with an error matching the condition.") + public init( + _ publisher: P, + condition: @escaping (P.Failure) -> Bool, + description expectationDescription: String = "Failure was expected with an error matching the condition.") { super.init(description: expectationDescription) cancellable = publisher.sink(receiveCompletion: { [weak self] completion in @@ -112,16 +120,19 @@ public final class PublisherFailureExpectation: XCTestExpectation } /// Initializes a PublisherFailureExpectation for a publisher with the given description - public convenience init(_ publisher: P, - description expectationDescription: String = "Failure was expected") + public convenience init( + _ publisher: P, + description expectationDescription: String = "Failure was expected") { self.init(publisher, condition: { _ in true }, description: expectationDescription) } /// Initializes a PublisherFailureExpectation that is fulfilled when the publisher fails with an expected error. - public convenience init(_ publisher: P, - expectedError: P.Failure, - description expectationDescription: String? = nil) where P.Failure: Equatable + public convenience init( + _ publisher: P, + expectedError: P.Failure, + description expectationDescription: String? = nil + ) where P.Failure: Equatable { let description = expectationDescription ?? "Failure was expected with '\(expectedError)'" self.init(publisher, condition: { $0 == expectedError }, description: description)