Skip to content

Commit

Permalink
[208] - Add XCTAssertNoWorkflowLaunched
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-nallick-wwt authored and Nick Nallick committed Jun 23, 2022
1 parent c8eed36 commit ce1cb33
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Sources/SwiftCurrent_Testing/CustomAssertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ public func XCTAssertWorkflowLaunched<F>(from VC: UIViewController, workflow: Wo

/// 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)
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,
listenerWorkflow.count == workflow.count else {
Expand All @@ -45,5 +46,10 @@ public func XCTAssertWorkflowLaunched(from VC: UIViewController, workflow: AnyWo
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

0 comments on commit ce1cb33

Please sign in to comment.