Skip to content

Commit fc8bc23

Browse files
Merge pull request #207 from nallick/main
2 parents d40dc8f + ce1cb33 commit fc8bc23

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Sources/SwiftCurrent_Testing/CustomAssertions.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ import UIKit
1818
#if !os(watchOS)
1919
/// Assert that a workflow was launched and matches the workflow passed in
2020
public func XCTAssertWorkflowLaunched<F>(from VC: UIViewController, workflow: Workflow<F>, file: StaticString = #filePath, line: UInt = #line) {
21+
XCTAssertWorkflowLaunched(from: VC, workflow: AnyWorkflow(workflow), file: file, line: line)
22+
}
23+
24+
/// Assert that a workflow was launched and matches the workflow passed in
25+
public func XCTAssertWorkflowLaunched(from VC: UIViewController, workflow: AnyWorkflow?, file: StaticString = #filePath, line: UInt = #line) {
26+
guard let workflow = workflow else {
27+
XCTAssertNoWorkflowLaunched(from: VC, file: file, line: line)
28+
return
29+
}
30+
2131
let last = VC.launchedWorkflows.last
2232
XCTAssertNotNil(last, "No workflow found", file: file, line: line)
2333
guard let listenerWorkflow = last,
@@ -36,5 +46,10 @@ public func XCTAssertWorkflowLaunched<F>(from VC: UIViewController, workflow: Wo
3646
XCTAssert(actual == expected, "Expected type: \(expected), but got: \(actual)", file: file, line: line)
3747
}
3848
}
49+
50+
/// Assert that no workflow was launched
51+
public func XCTAssertNoWorkflowLaunched(from VC: UIViewController, file: StaticString = #filePath, line: UInt = #line) {
52+
XCTAssertNil(VC.launchedWorkflows.last, "workflow found when none expected", file: file, line: line)
53+
}
3954
#endif
4055
#endif

0 commit comments

Comments
 (0)