Fix tutorials (#2355)

* add deleted code

* fix compile error

* fix doc link

* add for alert
This commit is contained in:
hmhv
2023-08-07 07:22:21 +09:00
committed by GitHub
parent 3d64d73d7c
commit 4b10e450f9
6 changed files with 7 additions and 4 deletions

View File

@@ -21,6 +21,8 @@ struct ContactsFeature: Reducer {
return .none
case let .addContact(.presented(.delegate(.saveContact(contact)))):
// guard let contact = state.addContact?.contact
// else { return .none }
state.contacts.append(contact)
state.addContact = nil
return .none

View File

@@ -22,7 +22,7 @@ final class ContactsFeatureTests: XCTestCase {
AlertState {
TextState("Are you sure?")
} actions: {
ButtonState(role: .destructive, action: .confirmDeletion(id: id)) {
ButtonState(role: .destructive, action: .confirmDeletion(id: UUID(1))) {
TextState("Delete")
}
}

View File

@@ -18,7 +18,7 @@ final class ContactsFeatureTests: XCTestCase {
}
await store.send(.deleteButtonTapped(id: UUID(1))) {
state.destination = .alert(.deleteConfirmation(id: UUID(1)))
$0.destination = .alert(.deleteConfirmation(id: UUID(1)))
}
}
}

View File

@@ -18,7 +18,7 @@ final class ContactsFeatureTests: XCTestCase {
}
await store.send(.deleteButtonTapped(id: UUID(1))) {
state.destination = .alert(.deleteConfirmation(id: UUID(1)))
$0.destination = .alert(.deleteConfirmation(id: UUID(1)))
}
await store.send(.destination(.presented(.alert(.confirmDeletion(id: UUID(1)))))) {
}

View File

@@ -210,7 +210,7 @@
Next we want to assert that sometime after the user taps the "Save" button that the
contact is added to the array and the child feature is dismissed. However, we cannot assert
on that until all the actions have been received, and so we can do that by using
``ComposableArchitecture/TestStore/skipReceivedActions(strict:file:line:)-a4ri``.
``ComposableArchitecture/TestStore/skipreceivedactions(strict:file:line:)``.
@Code(name: "ContactsFeatureTests.swift", file: 02-03-02-code-0005)
}

View File

@@ -34,6 +34,7 @@ struct ContactDetailFeature: Reducer {
return .none
}
}
.ifLet(\.$alert, action: /Action.alert)
}
}