Files
downterm/CommandNotch/CommandNotchTests/AppSettingsControllerTests.swift

49 lines
1.8 KiB
Swift

import XCTest
@testable import CommandNotch
@MainActor
final class AppSettingsControllerTests: XCTestCase {
func testTerminalSessionConfigurationIncludesShellPath() {
let store = InMemoryAppSettingsStore()
var settings = AppSettings.default
settings.terminal.shellPath = "/opt/homebrew/bin/fish"
settings.terminal.scrollbackLines = 12_000
settings.terminal.backendRawValue = TerminalBackendPreference.swiftTerm.rawValue
settings.terminal.termTypeRawValue = TerminalTermTypePreference.xterm256color.rawValue
store.storedSettings = settings
let controller = AppSettingsController(store: store)
XCTAssertEqual(controller.terminalSessionConfiguration.shellPath, "/opt/homebrew/bin/fish")
XCTAssertEqual(controller.terminalSessionConfiguration.scrollbackLines, 12_000)
XCTAssertEqual(controller.terminalSessionConfiguration.backendPreference, .swiftTerm)
XCTAssertEqual(controller.terminalSessionConfiguration.termTypePreference, .xterm256color)
}
func testTerminalSizePresetsDecodeFromTypedSettings() {
let store = InMemoryAppSettingsStore()
let presets = [
TerminalSizePreset(name: "Wide", width: 960, height: 420, hotkey: .cmdShiftDigit(4))
]
var settings = AppSettings.default
settings.terminal.sizePresetsJSON = TerminalSizePresetStore.encodePresets(presets)
store.storedSettings = settings
let controller = AppSettingsController(store: store)
XCTAssertEqual(controller.terminalSizePresets, presets)
}
}
private final class InMemoryAppSettingsStore: AppSettingsStoreType {
var storedSettings = AppSettings.default
func load() -> AppSettings {
storedSettings
}
func save(_ settings: AppSettings) {
storedSettings = settings
}
}