From c8eed361c22045d1872dd9413864e297cdeca1b4 Mon Sep 17 00:00:00 2001 From: Nick Nallick Date: Mon, 13 Jun 2022 09:32:13 -0600 Subject: [PATCH] [208] - Add variation of XCTAssertWorkflowLaunched for use with AnyWorkflow --- Sources/SwiftCurrent_Testing/CustomAssertions.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sources/SwiftCurrent_Testing/CustomAssertions.swift b/Sources/SwiftCurrent_Testing/CustomAssertions.swift index 28f837234..b395b404d 100644 --- a/Sources/SwiftCurrent_Testing/CustomAssertions.swift +++ b/Sources/SwiftCurrent_Testing/CustomAssertions.swift @@ -18,7 +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) { 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 {