Files
swift-composable-architectu…/Examples/SyncUps/SyncUpsTests/SyncUpFormTests.swift
Stephen Celis a611f141dd Standups -> SyncUps (#2524)
* Standups -> SyncUps

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
2023-10-17 14:13:36 -07:00

91 lines
2.1 KiB
Swift

import ComposableArchitecture
import XCTest
@testable import SyncUps
@MainActor
final class SyncUpFormTests: XCTestCase {
func testAddAttendee() async {
let store = TestStore(
initialState: SyncUpForm.State(
syncUp: SyncUp(
id: SyncUp.ID(),
attendees: [],
title: "Engineering"
)
)
) {
SyncUpForm()
} withDependencies: {
$0.uuid = .incrementing
}
XCTAssertNoDifference(
store.state.syncUp.attendees,
[
Attendee(id: Attendee.ID(UUID(0)))
]
)
await store.send(.addAttendeeButtonTapped) {
$0.focus = .attendee(Attendee.ID(UUID(1)))
$0.syncUp.attendees = [
Attendee(id: Attendee.ID(UUID(0))),
Attendee(id: Attendee.ID(UUID(1))),
]
}
}
func testFocus_RemoveAttendee() async {
let store = TestStore(
initialState: SyncUpForm.State(
syncUp: SyncUp(
id: SyncUp.ID(),
attendees: [
Attendee(id: Attendee.ID()),
Attendee(id: Attendee.ID()),
Attendee(id: Attendee.ID()),
Attendee(id: Attendee.ID()),
],
title: "Engineering"
)
)
) {
SyncUpForm()
} withDependencies: {
$0.uuid = .incrementing
}
await store.send(.deleteAttendees(atOffsets: [0])) {
$0.focus = .attendee($0.syncUp.attendees[1].id)
$0.syncUp.attendees = [
$0.syncUp.attendees[1],
$0.syncUp.attendees[2],
$0.syncUp.attendees[3],
]
}
await store.send(.deleteAttendees(atOffsets: [1])) {
$0.focus = .attendee($0.syncUp.attendees[2].id)
$0.syncUp.attendees = [
$0.syncUp.attendees[0],
$0.syncUp.attendees[2],
]
}
await store.send(.deleteAttendees(atOffsets: [1])) {
$0.focus = .attendee($0.syncUp.attendees[0].id)
$0.syncUp.attendees = [
$0.syncUp.attendees[0]
]
}
await store.send(.deleteAttendees(atOffsets: [0])) {
$0.focus = .attendee(Attendee.ID(UUID(0)))
$0.syncUp.attendees = [
Attendee(id: Attendee.ID(UUID(0)))
]
}
}
}