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

Tutorial Formatting Fixes #101

Merged
merged 2 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions Samples/Tutorial/Tutorial4.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,9 @@ Is the code better after this refactor? It's debatable - having the logic in the
Additionally, now the `TodoList` and `TodoEdit` workflows are completely decoupled - there is no longer a requirement that the `TodoEdit` workflow is displayed after the list. For instance, we could change the list to have "viewing" or "editing" modes, where tapping on an item might only allow it to be viewed, but another mode would allow editing.

It comes down to the individual judgement of the developer to decide how a tree of workflows should be shaped - this was intended to provide two examples of how this _could_ be structured, but not specify how it _should_.

## Up Next

We now have a pretty fully formed app. However, if we want to keep adding features, we'll want to validate that existing features don't break while we're making improvements. In the next tutorial, we'll cover a couple of techniques for testing workflows.

[Tutorial 5](Tutorial5.md)
36 changes: 18 additions & 18 deletions Samples/Tutorial/Tutorial5.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,24 +578,24 @@ class TodoWorkflowTests: XCTestCase {
step: .list
))
// We only expect the TodoListWorkflow to be rendered.
.expectWorkflow(
type: TodoListWorkflow.self,
producingRendering: BackStackScreen<AnyScreen>.Item(
screen: TodoListScreen(todoTitles: ["Title"], onTodoSelected: { _ in }).asAnyScreen()
),
// Simulate selecting the first todo.
producingOutput: .selectTodo(index: 0)
)
.render { items in
// Just validate that there is one item in the back stack.
// Additional validation could be done on the screens returned, if desired.
XCTAssertEqual(1, items.count)
}
// Assert that the state was updated after the render pass with the output from the TodoListWorkflow.
.assert(state: TodoWorkflow.State(
todos: [TodoModel(title: "Title", note: "Note")],
step: .edit(index: 0)
))
.expectWorkflow(
type: TodoListWorkflow.self,
producingRendering: BackStackScreen<AnyScreen>.Item(
screen: TodoListScreen(todoTitles: ["Title"], onTodoSelected: { _ in }).asAnyScreen()
),
// Simulate selecting the first todo.
producingOutput: .selectTodo(index: 0)
)
.render { items in
// Just validate that there is one item in the back stack.
// Additional validation could be done on the screens returned, if desired.
XCTAssertEqual(1, items.count)
}
// Assert that the state was updated after the render pass with the output from the TodoListWorkflow.
.assert(state: TodoWorkflow.State(
todos: [TodoModel(title: "Title", note: "Note")],
step: .edit(index: 0)
))
}

func testSavingTodo() throws {
Expand Down