86 lines
2.0 KiB
Swift
86 lines
2.0 KiB
Swift
import ComposableArchitecture
|
|
import PressureEstimationsFeature
|
|
import SharedModels
|
|
import Testing
|
|
import XCTest
|
|
|
|
struct RatedStaticPressureStateTests {
|
|
|
|
@Test(
|
|
"Rated static pressure validation",
|
|
.tags(.ratedStaticPressuresSection)
|
|
)
|
|
func validation() {
|
|
var state = RatedStaticPressuresSection.State(
|
|
staticPressures: Shared(RatedStaticPressures())
|
|
)
|
|
#expect(state.isValid)
|
|
|
|
state.maxPressure = nil
|
|
#expect(!state.isValid)
|
|
|
|
state.maxPressure = 1
|
|
state.minPressure = nil
|
|
#expect(!state.isValid)
|
|
|
|
state.minPressure = 1
|
|
state.ratedPressure = nil
|
|
#expect(!state.isValid)
|
|
|
|
state.ratedPressure = 1
|
|
#expect(state.isValid)
|
|
}
|
|
|
|
@Test(
|
|
"Focused field label",
|
|
.tags(.ratedStaticPressuresSection),
|
|
arguments: RatedStaticPressuresSection.State.FocusedField.allCases
|
|
)
|
|
func label(field: RatedStaticPressuresSection.State.FocusedField) {
|
|
#expect(field.label == "\(field.rawValue.capitalized)")
|
|
}
|
|
|
|
@Test(
|
|
"Focused field prompt",
|
|
.tags(.ratedStaticPressuresSection),
|
|
arguments: RatedStaticPressuresSection.State.FocusedField.allCases
|
|
)
|
|
func prompt(field: RatedStaticPressuresSection.State.FocusedField) {
|
|
#expect(field.prompt == "\(field.rawValue.capitalized) Pressure")
|
|
}
|
|
|
|
}
|
|
|
|
final class RatedStaticPressureReducerTests: XCTestCase {
|
|
|
|
@MainActor
|
|
func testBindingsSetSharedState() async {
|
|
let store = TestStore(
|
|
initialState: RatedStaticPressuresSection.State(
|
|
staticPressures: Shared(RatedStaticPressures())
|
|
)
|
|
) {
|
|
RatedStaticPressuresSection()
|
|
}
|
|
|
|
await store.send(.binding(.set(\.maxPressure, nil))) {
|
|
$0.maxPressure = nil
|
|
$0.staticPressures.maximum = 0
|
|
}
|
|
await store.send(.binding(.set(\.minPressure, nil))) {
|
|
$0.minPressure = nil
|
|
$0.staticPressures.minimum = 0
|
|
}
|
|
await store.send(.binding(.set(\.ratedPressure, nil))) {
|
|
$0.ratedPressure = nil
|
|
$0.staticPressures.rated = 0
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
extension Tag {
|
|
|
|
@Tag static var ratedStaticPressuresSection: Self
|
|
}
|