import XCTest
@testable import CxWebAppMac

final class AppSettingsTests: XCTestCase {

    @MainActor
    func testDefaultsWhenEmpty() {
        UserDefaults.standard.removeObject(forKey: "backendURL")
        UserDefaults.standard.removeObject(forKey: "autoReloadSeconds")
        UserDefaults.standard.removeObject(forKey: "developerExtras")

        let s = AppSettings()
        XCTAssertFalse(s.backendURL.isEmpty)
        XCTAssertEqual(s.autoReloadSeconds, 0)
        XCTAssertFalse(s.developerExtras)
    }

    @MainActor
    func testBackendURLPersists() {
        let s = AppSettings()
        s.backendURL = "http://127.0.0.1:9999"
        let s2 = AppSettings()
        XCTAssertEqual(s2.backendURL, "http://127.0.0.1:9999")
    }
}
