Skip to content

Commit ac2e7ac

Browse files
Fix "Composing features" tutorial (#2698)
* Fix the filename * Add `@MainActor` and `async` for testing the feature --------- Co-authored-by: Stephen Celis <[email protected]>
1 parent ae491c9 commit ac2e7ac

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import ComposableArchitecture
22
import XCTest
33

4-
class AppFeatureTests: XCTestCase {
5-
func testIncrementInFirstTab() {
4+
@MainActor
5+
final class AppFeatureTests: XCTestCase {
6+
func testIncrementInFirstTab() async {
67

78
}
89
}

Sources/ComposableArchitecture/Documentation.docc/Tutorials/MeetTheComposableArchitecture/01-Essentials/04-ComposingFeatures/01-04-02-code-0006.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import ComposableArchitecture
22
import XCTest
33

4-
class AppFeatureTests: XCTestCase {
5-
func testIncrementInFirstTab() {
4+
@MainActor
5+
final class AppFeatureTests: XCTestCase {
6+
func testIncrementInFirstTab() async {
67
let store = TestStore(initialState: AppFeature.State()) {
78
AppFeature()
89
}

Sources/ComposableArchitecture/Documentation.docc/Tutorials/MeetTheComposableArchitecture/01-Essentials/04-ComposingFeatures/01-04-02-code-0007.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import ComposableArchitecture
22
import XCTest
33

4-
class AppFeatureTests: XCTestCase {
5-
func testIncrementInFirstTab() {
4+
@MainActor
5+
final class AppFeatureTests: XCTestCase {
6+
func testIncrementInFirstTab() async {
67
let store = TestStore(initialState: AppFeature.State()) {
78
AppFeature()
89
}

Sources/ComposableArchitecture/Documentation.docc/Tutorials/MeetTheComposableArchitecture/01-Essentials/04-ComposingFeatures/01-04-02-code-0008.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import ComposableArchitecture
22
import XCTest
33

4-
class AppFeatureTests: XCTestCase {
5-
func testIncrementInFirstTab() {
4+
@MainActor
5+
final class AppFeatureTests: XCTestCase {
6+
func testIncrementInFirstTab() async {
67
let store = TestStore(initialState: AppFeature.State()) {
78
AppFeature()
89
}

Sources/ComposableArchitecture/Documentation.docc/Tutorials/MeetTheComposableArchitecture/01-Essentials/04-ComposingFeatures/01-04-ComposingFeatures.tutorial

+4-4
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
@Step {
188188
Replace the two individual store properties with a single store of the `AppFeature` domain.
189189

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

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

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

202202
@Step {
203203
And do the same for the second tab.
204204

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

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

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

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

0 commit comments

Comments
 (0)