diff --git a/WorkflowCombine/Testing/PublisherTesting.swift b/WorkflowCombine/Testing/PublisherTesting.swift index bfd3999d0..30edfc6e6 100644 --- a/WorkflowCombine/Testing/PublisherTesting.swift +++ b/WorkflowCombine/Testing/PublisherTesting.swift @@ -23,16 +23,17 @@ import XCTest @testable import WorkflowCombine extension RenderTester { - /// Expect a `Publisher`s. + /// Expect a `Publisher`-based Workflow. /// /// `PublisherWorkflow` is used to subscribe to `Publisher`s. /// /// - Parameters: + /// - publisher: Type of the Publisher-based Workflow to expect /// - producingOutput: An output that should be returned when this worker is requested, if any. /// - key: Key to expect this `Workflow` to be rendered with. public func expect( publisher: PublisherType.Type, - output: PublisherType.Output, + producingOutput output: PublisherType.Output? = nil, key: String = "" ) -> RenderTester where PublisherType.Failure == Never { expectWorkflow( @@ -43,6 +44,19 @@ extension RenderTester { assertions: { _ in } ) } + + @available(*, deprecated, renamed: "expect(publisher:producingOutput:key:)") + public func expect( + publisher: PublisherType.Type, + output: PublisherType.Output, + key: String = "" + ) -> RenderTester where PublisherType.Failure == Never { + expect( + publisher: publisher, + producingOutput: output, + key: key + ) + } } #endif diff --git a/WorkflowCombine/TestingTests/PublisherTests.swift b/WorkflowCombine/TestingTests/PublisherTests.swift index f7c2f4ed5..fe27d2d33 100644 --- a/WorkflowCombine/TestingTests/PublisherTests.swift +++ b/WorkflowCombine/TestingTests/PublisherTests.swift @@ -16,10 +16,26 @@ class PublisherTests: XCTestCase { func testPublisherWorkflow() { TestWorkflow() .renderTester() - .expect(publisher: Publishers.Sequence<[Int], Never>.self, output: 1, key: "123") + .expect( + publisher: Publishers.Sequence<[Int], Never>.self, + producingOutput: 1, + key: "123" + ) .render {} } + func test_publisher_no_output() { + TestWorkflow() + .renderTester() + .expect( + publisher: Publishers.Sequence<[Int], Never>.self, + producingOutput: nil, + key: "123" + ) + .render {} + .assertNoAction() + } + struct TestWorkflow: Workflow { typealias State = Void typealias Rendering = Void