Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add variation of XCTAssertWorkflowLaunched for use with AnyWorkflow #207

Merged
merged 2 commits into from
Jul 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Sources/SwiftCurrent_Testing/CustomAssertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +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) {
nallick marked this conversation as resolved.
Show resolved Hide resolved
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,
Expand All @@ -36,5 +46,10 @@ public func XCTAssertWorkflowLaunched<F>(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