Skip to content

Commit

Permalink
[208] - Add variation of XCTAssertWorkflowLaunched for use with AnyWo…
Browse files Browse the repository at this point in the history
…rkflow
  • Loading branch information
nick-nallick-wwt authored and Nick Nallick committed Jun 23, 2022
1 parent d40dc8f commit c8eed36
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/SwiftCurrent_Testing/CustomAssertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ import UIKit
#if !os(watchOS)
/// Assert that a workflow was launched and matches the workflow passed in
public func XCTAssertWorkflowLaunched<F>(from VC: UIViewController, workflow: Workflow<F>, file: StaticString = #filePath, line: UInt = #line) {
XCTAssertWorkflowLaunched(from: VC, workflow: AnyWorkflow(workflow), file: file, line: line)
}

/// Assert that a workflow was launched and matches the workflow passed in
public func XCTAssertWorkflowLaunched(from VC: UIViewController, workflow: AnyWorkflow?, file: StaticString = #filePath, line: UInt = #line) {
let last = VC.launchedWorkflows.last
guard let workflow = workflow else {
XCTAssertNil(last, "workflow found when none expected", file: file, line: line)
return
}
XCTAssertNotNil(last, "No workflow found", file: file, line: line)
guard let listenerWorkflow = last,
listenerWorkflow.count == workflow.count else {
Expand Down

0 comments on commit c8eed36

Please sign in to comment.