feat: Begins equipment settings form tests.
This commit is contained in:
@@ -91,15 +91,15 @@ public struct EquipmentSettingsForm {
|
||||
switch action {
|
||||
|
||||
case .binding(\.maxStaticPressure):
|
||||
handleStaticPressure(\.maximum, \.maxStaticPressure, &state)
|
||||
state.sharedSettings.handleStaticPressure(\.maximum, state.maxStaticPressure)
|
||||
return .none
|
||||
|
||||
case .binding(\.minStaticPressure):
|
||||
handleStaticPressure(\.minimum, \.minStaticPressure, &state)
|
||||
state.sharedSettings.handleStaticPressure(\.maximum, state.minStaticPressure)
|
||||
return .none
|
||||
|
||||
case .binding(\.ratedStaticPressure):
|
||||
handleStaticPressure(\.rated, \.ratedStaticPressure, &state)
|
||||
state.sharedSettings.handleStaticPressure(\.rated, state.ratedStaticPressure)
|
||||
return .none
|
||||
|
||||
case .binding:
|
||||
@@ -133,16 +133,15 @@ public struct EquipmentSettingsForm {
|
||||
.ifLet(\.$destination, action: \.destination)
|
||||
}
|
||||
|
||||
private func handleStaticPressure(
|
||||
_ staticKeyPath: WritableKeyPath<RatedStaticPressures, Double>,
|
||||
_ stateKeyPath: KeyPath<State, Double?>,
|
||||
_ state: inout State
|
||||
}
|
||||
|
||||
extension SharedPressureEstimationState {
|
||||
mutating func handleStaticPressure(
|
||||
_ keyPath: WritableKeyPath<RatedStaticPressures, Double>,
|
||||
_ value: Double?
|
||||
) {
|
||||
let value = state[keyPath: stateKeyPath]
|
||||
state.sharedSettings.equipmentMetadata.ratedStaticPressures[keyPath: staticKeyPath] = value ?? 0
|
||||
|
||||
equipmentMetadata.ratedStaticPressures[keyPath: keyPath] = value ?? 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ViewAction(for: EquipmentSettingsForm.self)
|
||||
@@ -256,12 +255,6 @@ public struct EquipmentSettingsFormView: View {
|
||||
|
||||
Section {
|
||||
VStack(alignment: .leading) {
|
||||
// HStack {
|
||||
// TextLabel("Includes Filter Drop")
|
||||
// Spacer()
|
||||
// Toggle("Includes Filter Drop", isOn: $store.includesFilterDrop)
|
||||
// }
|
||||
// if store.includesFilterDrop {
|
||||
HStack {
|
||||
TextLabel("Filter Drop")
|
||||
Spacer()
|
||||
@@ -273,7 +266,6 @@ public struct EquipmentSettingsFormView: View {
|
||||
.decimalPad()
|
||||
.padding(.leading, 40)
|
||||
}
|
||||
// }
|
||||
}
|
||||
} header: {
|
||||
header(infoView: .manufacturersIncludedFilterPressureDrop) {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import ComposableArchitecture
|
||||
@testable import PressureEstimationsFeature
|
||||
import Testing
|
||||
import XCTest
|
||||
|
||||
struct EquipmentSettingsFormStateTests {
|
||||
|
||||
@Test(
|
||||
"Ensure setting static pressure",
|
||||
.tags(.equipmentSettingsForm),
|
||||
arguments: [Optional<Double>(42), nil]
|
||||
)
|
||||
func setStaticPressure(staticPressure: Double?) {
|
||||
var sharedSettings = SharedPressureEstimationState()
|
||||
|
||||
sharedSettings.handleStaticPressure(\.maximum, staticPressure)
|
||||
sharedSettings.handleStaticPressure(\.minimum, staticPressure)
|
||||
sharedSettings.handleStaticPressure(\.rated, staticPressure)
|
||||
|
||||
if let staticPressure {
|
||||
#expect(sharedSettings.equipmentMetadata.ratedStaticPressures.maximum == staticPressure)
|
||||
#expect(sharedSettings.equipmentMetadata.ratedStaticPressures.minimum == staticPressure)
|
||||
#expect(sharedSettings.equipmentMetadata.ratedStaticPressures.rated == staticPressure)
|
||||
} else {
|
||||
#expect(sharedSettings.equipmentMetadata.ratedStaticPressures.maximum == 0)
|
||||
#expect(sharedSettings.equipmentMetadata.ratedStaticPressures.minimum == 0)
|
||||
#expect(sharedSettings.equipmentMetadata.ratedStaticPressures.rated == 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final class EquipmentSettingsFormTests: XCTestCase {
|
||||
|
||||
|
||||
}
|
||||
|
||||
extension Tag {
|
||||
@Tag static var equipmentSettingsForm: Self
|
||||
}
|
||||
Reference in New Issue
Block a user