diff --git a/Sources/SwiftCurrent_Testing/CustomAssertions.swift b/Sources/SwiftCurrent_Testing/CustomAssertions.swift index 28f837234..3bb18c384 100644 --- a/Sources/SwiftCurrent_Testing/CustomAssertions.swift +++ b/Sources/SwiftCurrent_Testing/CustomAssertions.swift @@ -18,6 +18,16 @@ import UIKit #if !os(watchOS) /// Assert that a workflow was launched and matches the workflow passed in public func XCTAssertWorkflowLaunched(from VC: UIViewController, workflow: Workflow, 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) { + guard let workflow = workflow else { + XCTAssertNoWorkflowLaunched(from: VC, file: file, line: line) + return + } + let last = VC.launchedWorkflows.last XCTAssertNotNil(last, "No workflow found", file: file, line: line) guard let listenerWorkflow = last, @@ -36,5 +46,10 @@ public func XCTAssertWorkflowLaunched(from VC: UIViewController, workflow: Wo XCTAssert(actual == expected, "Expected type: \(expected), but got: \(actual)", file: file, line: line) } } + +/// Assert that no workflow was launched +public func XCTAssertNoWorkflowLaunched(from VC: UIViewController, file: StaticString = #filePath, line: UInt = #line) { + XCTAssertNil(VC.launchedWorkflows.last, "workflow found when none expected", file: file, line: line) +} #endif #endif