-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 351: Update input to root workflow in WorkflowHost
Resolves #351
- Loading branch information
Dave Apgar
committed
Jul 23, 2019
1 parent
65445fb
commit b7f9d09
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import XCTest | ||
import Workflow | ||
|
||
|
||
final class WorkflowHostTests: XCTestCase { | ||
|
||
func test_updatedInputCausesRenderPass() { | ||
let host = WorkflowHost(workflow: TestWorkflow(step: .first)) | ||
|
||
XCTAssertEqual(1, host.rendering.value) | ||
|
||
host.update(workflow: TestWorkflow(step: .second)) | ||
|
||
XCTAssertEqual(2, host.rendering.value) | ||
} | ||
|
||
fileprivate struct TestWorkflow: Workflow { | ||
var step: Step | ||
enum Step { | ||
case first | ||
case second | ||
} | ||
|
||
struct State {} | ||
func makeInitialState() -> State { | ||
return State() | ||
} | ||
|
||
func workflowDidChange(from previousWorkflow: TestWorkflow, state: inout State) { | ||
} | ||
|
||
typealias Rendering = Int | ||
|
||
func render(state: State, context: RenderContext<TestWorkflow>) -> Rendering { | ||
switch self.step { | ||
case .first: | ||
return 1 | ||
case .second: | ||
return 2 | ||
} | ||
} | ||
} | ||
} |