Fix "Composing features" tutorial (#2698)

* Fix the filename

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

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
This commit is contained in:
Shinichiro Oba
2024-01-09 03:50:11 +09:00
committed by GitHub
parent ae491c9e3f
commit ac2e7ac1bc
5 changed files with 16 additions and 12 deletions

View File

@@ -1,8 +1,9 @@
import ComposableArchitecture
import XCTest
class AppFeatureTests: XCTestCase {
func testIncrementInFirstTab() {
@MainActor
final class AppFeatureTests: XCTestCase {
func testIncrementInFirstTab() async {
}
}

View File

@@ -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()
}

View File

@@ -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()
}

View File

@@ -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()
}

View File

@@ -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 {
@@ -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
@@ -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