Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public final class Preferences {
/// The unavailable modules are ones this Mac can't show, such as battery on a desktop.
public init(
defaults: UserDefaults = .standard,
locale: Locale = .autoupdatingCurrent,
unavailableMenuBarModules: Set<MenuBarModule> = []
) {
self.defaults = defaults
Expand All @@ -81,8 +80,7 @@ public final class Preferences {
unavailable: unavailableMenuBarModules
)
refreshInterval = RefreshInterval(rawValue: defaults.integer(forKey: Key.refreshInterval)) ?? .twoSeconds
temperatureUnit = defaults.string(forKey: Key.temperatureUnit).flatMap(TemperatureUnit.init(rawValue:))
?? (locale.measurementSystem == .us ? .fahrenheit : .celsius)
temperatureUnit = defaults.string(forKey: Key.temperatureUnit).flatMap(TemperatureUnit.init(rawValue:)) ?? .celsius
networkInterface = defaults.string(forKey: Key.networkInterface).map(NetworkInterfaceChoice.named) ?? .automatic
dashboardStyle = defaults.string(forKey: Key.dashboardStyle).flatMap(DashboardStyle.init(rawValue:)) ?? .cluster
dashboardSectionOrder = Self.complete(Self.decode(defaults.stringArray(forKey: Key.dashboardSectionOrder)) ?? [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ struct PreferencesTests {
#expect(Preferences(defaults: defaults).networkInterface == .automatic)
}

@Test(arguments: [("en_US", TemperatureUnit.fahrenheit), ("en_GB", .celsius)])
func temperatureUnitDefaultsToTheLocale(identifier: String, expected: TemperatureUnit) {
#expect(Preferences(defaults: defaults, locale: Locale(identifier: identifier)).temperatureUnit == expected)
@Test func temperatureUnitDefaultsToCelsius() {
#expect(Preferences(defaults: defaults).temperatureUnit == .celsius)
}

@Test func dashboardStyleDefaultsToTheCluster() {
Expand Down
Loading