Files
swift-composable-architectu…/Examples/CaseStudies/UIKitCaseStudiesTests/UIKitCaseStudiesTests.swift
Stephen Celis 85417e000e Update documentation and examples to use Swift Testing (#3413)
* Testing: Case Studies

* Testing: Search

* Testing: Speech Recognition

* Testing: SyncUps

* Project Settings

* Testing: TicTacToe

* Testing: Todos

* Testing: Voice Memos

* Update tutorials/docs

* fix

* Fixes

* wip

* Update ci.yml

* Update ci.yml

* Update ci.yml

* wip

* wip

* Quiet

* fix

* wip

* wip

* flaky

* wip

* wip

* fix
2024-10-02 16:28:33 -07:00

57 lines
1.4 KiB
Swift

import ComposableArchitecture
import Testing
@testable import UIKitCaseStudies
@MainActor
@Test
func countDown() async {
let store = TestStore(initialState: Counter.State()) {
Counter()
}
await store.send(.incrementButtonTapped) {
$0.count = 1
}
await store.send(.decrementButtonTapped) {
$0.count = 0
}
}
@MainActor
@Test
func countDownList() async {
let firstState = Counter.State()
let secondState = Counter.State()
let thirdState = Counter.State()
let store = TestStore(
initialState: CounterList.State(
counters: [firstState, secondState, thirdState]
)
) {
CounterList()
}
await store.send(\.counters[id: firstState.id].incrementButtonTapped) {
$0.counters[id: firstState.id]?.count = 1
}
await store.send(\.counters[id: firstState.id].decrementButtonTapped) {
$0.counters[id: firstState.id]?.count = 0
}
await store.send(\.counters[id: secondState.id].incrementButtonTapped) {
$0.counters[id: secondState.id]?.count = 1
}
await store.send(\.counters[id: secondState.id].decrementButtonTapped) {
$0.counters[id: secondState.id]?.count = 0
}
await store.send(\.counters[id: thirdState.id].incrementButtonTapped) {
$0.counters[id: thirdState.id]?.count = 1
}
await store.send(\.counters[id: thirdState.id].decrementButtonTapped) {
$0.counters[id: thirdState.id]?.count = 0
}
}