Fix component library tests and cover 0.0 V case
ComponentLibraryItem gained componentCategory, which left the test target uncompilable. Add the argument to all call sites and a regression test for displayVoltage skipping a zero voltageIn.
This commit is contained in:
@@ -14,6 +14,7 @@ struct ComponentLibraryItemTests {
|
||||
watt: nil,
|
||||
dutyCyclePercent: nil,
|
||||
defaultUtilizationFactorPercent: nil,
|
||||
componentCategory: nil,
|
||||
iconURL: nil,
|
||||
)
|
||||
|
||||
@@ -31,6 +32,7 @@ struct ComponentLibraryItemTests {
|
||||
watt: nil,
|
||||
dutyCyclePercent: nil,
|
||||
defaultUtilizationFactorPercent: nil,
|
||||
componentCategory: nil,
|
||||
iconURL: nil,
|
||||
)
|
||||
|
||||
@@ -51,6 +53,7 @@ struct ComponentLibraryItemTests {
|
||||
watt: nil,
|
||||
dutyCyclePercent: nil,
|
||||
defaultUtilizationFactorPercent: nil,
|
||||
componentCategory: nil,
|
||||
iconURL: nil,
|
||||
)
|
||||
|
||||
@@ -68,6 +71,7 @@ struct ComponentLibraryItemTests {
|
||||
watt: nil,
|
||||
dutyCyclePercent: nil,
|
||||
defaultUtilizationFactorPercent: nil,
|
||||
componentCategory: nil,
|
||||
iconURL: nil,
|
||||
)
|
||||
|
||||
@@ -85,6 +89,7 @@ struct ComponentLibraryItemTests {
|
||||
watt: nil,
|
||||
dutyCyclePercent: nil,
|
||||
defaultUtilizationFactorPercent: nil,
|
||||
componentCategory: nil,
|
||||
iconURL: nil,
|
||||
)
|
||||
|
||||
@@ -102,6 +107,7 @@ struct ComponentLibraryItemTests {
|
||||
watt: nil,
|
||||
dutyCyclePercent: nil,
|
||||
defaultUtilizationFactorPercent: nil,
|
||||
componentCategory: nil,
|
||||
iconURL: nil,
|
||||
)
|
||||
|
||||
@@ -119,6 +125,7 @@ struct ComponentLibraryItemTests {
|
||||
watt: nil,
|
||||
dutyCyclePercent: 0,
|
||||
defaultUtilizationFactorPercent: nil,
|
||||
componentCategory: nil,
|
||||
iconURL: nil,
|
||||
)
|
||||
|
||||
@@ -135,9 +142,27 @@ struct ComponentLibraryItemTests {
|
||||
watt: nil,
|
||||
dutyCyclePercent: nil,
|
||||
defaultUtilizationFactorPercent: 50,
|
||||
componentCategory: nil,
|
||||
iconURL: nil,
|
||||
)
|
||||
|
||||
#expect(item.defaultDailyUsageHours == 12)
|
||||
}
|
||||
|
||||
@Test func displayVoltageIgnoresZeroInputVoltage() async throws {
|
||||
let item = ComponentLibraryItem(
|
||||
id: "component-9",
|
||||
name: "Library Battery",
|
||||
translations: [:],
|
||||
voltageIn: 0,
|
||||
voltageOut: 12.8,
|
||||
watt: nil,
|
||||
dutyCyclePercent: nil,
|
||||
defaultUtilizationFactorPercent: nil,
|
||||
componentCategory: nil,
|
||||
iconURL: nil,
|
||||
)
|
||||
|
||||
#expect(item.displayVoltage == 12.8)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user