Skip to content

Commit

Permalink
Fix "Composing features" tutorial (#2698)
Browse files Browse the repository at this point in the history
* Fix the filename

* Add `@MainActor` and `async` for testing the feature

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
  • Loading branch information
bricklife and stephencelis authored Jan 8, 2024
1 parent ae491c9 commit ac2e7ac
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import ComposableArchitecture
import XCTest

class AppFeatureTests: XCTestCase {
func testIncrementInFirstTab() {
@MainActor
final class AppFeatureTests: XCTestCase {
func testIncrementInFirstTab() async {

}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import ComposableArchitecture
import XCTest

class AppFeatureTests: XCTestCase {
func testIncrementInFirstTab() {
@MainActor
final class AppFeatureTests: XCTestCase {
func testIncrementInFirstTab() async {
let store = TestStore(initialState: AppFeature.State()) {
AppFeature()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import ComposableArchitecture
import XCTest

class AppFeatureTests: XCTestCase {
func testIncrementInFirstTab() {
@MainActor
final class AppFeatureTests: XCTestCase {
func testIncrementInFirstTab() async {
let store = TestStore(initialState: AppFeature.State()) {
AppFeature()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import ComposableArchitecture
import XCTest

class AppFeatureTests: XCTestCase {
func testIncrementInFirstTab() {
@MainActor
final class AppFeatureTests: XCTestCase {
func testIncrementInFirstTab() async {
let store = TestStore(initialState: AppFeature.State()) {
AppFeature()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
@Step {
Replace the two individual store properties with a single store of the `AppFeature` domain.

@Code(name: "AppFeatureTests.swift", file: 01-04-03-code-0001.swift, previousFile: 01-04-03-code-0001-previous.swift)
@Code(name: "AppFeature.swift", file: 01-04-03-code-0001.swift, previousFile: 01-04-03-code-0001-previous.swift)
}

@Step {
Expand All @@ -196,13 +196,13 @@
domain. This is done by using key path syntax to single out the field of the state and
the case of the action enum.

@Code(name: "AppFeatureTests.swift", file: 01-04-03-code-0002.swift)
@Code(name: "AppFeature.swift", file: 01-04-03-code-0002.swift)
}

@Step {
And do the same for the second tab.

@Code(name: "AppFeatureTests.swift", file: 01-04-03-code-0003.swift)
@Code(name: "AppFeature.swift", file: 01-04-03-code-0003.swift)
}

That is all it takes. We now have a single ``ComposableArchitecture/Store`` powering this
Expand All @@ -212,7 +212,7 @@
@Step {
Create a preview for `AppView` by initializing a store with the `AppFeature` domain.

@Code(name: "AppFeatureTests.swift", file: 01-04-03-code-0004.swift)
@Code(name: "AppFeature.swift", file: 01-04-03-code-0004.swift)
}

We can also run the feature in the simulator by updating the entry point of the app to be
Expand Down

0 comments on commit ac2e7ac

Please sign in to comment.