Files
suixinkan_uikit/suixinkanTests/AMapBootstrapTests.swift
汉秋 005349f8e6 模块化 AppStore 并完善素材管理与个人空间设置。
将会话、权限、位置、收款与排队存储拆分为独立模块,同步更新各 ViewModel 与单元测试,并补充素材管理 UI 与个人空间设置交互。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-13 11:01:08 +08:00

52 lines
1.6 KiB
Swift

//
// AMapBootstrapTests.swift
// suixinkanTests
//
import XCTest
@testable import suixinkan
/// SDK gate
final class AMapBootstrapTests: XCTestCase {
private var defaults: UserDefaults!
private var appStore: AppStore!
override func setUp() {
super.setUp()
AMapBootstrap.resetForTesting()
defaults = UserDefaults(suiteName: "AMapBootstrapTests")!
defaults.removePersistentDomain(forName: "AMapBootstrapTests")
appStore = AppStore(defaults: defaults)
}
override func tearDown() {
AMapBootstrap.resetForTesting()
super.tearDown()
}
func testConfigureReturnsFalseWhenPrivacyNotAccepted() {
appStore.session.privacyAgreementAccepted = false
XCTAssertFalse(AMapBootstrap.configureIfNeeded(appStore: appStore))
XCTAssertFalse(AMapBootstrap.isConfigured)
}
func testConfigureIsIdempotentWhenPrivacyAccepted() {
appStore.session.privacyAgreementAccepted = true
XCTAssertTrue(AMapBootstrap.configureIfNeeded(appStore: appStore))
XCTAssertTrue(AMapBootstrap.isConfigured)
XCTAssertTrue(AMapBootstrap.configureIfNeeded(appStore: appStore))
XCTAssertTrue(AMapBootstrap.isConfigured)
}
func testRequireConfiguredThrowsWhenPrivacyNotAccepted() {
appStore.session.privacyAgreementAccepted = false
XCTAssertThrowsError(try AMapBootstrap.requireConfigured(appStore: appStore)) { error in
XCTAssertEqual(error as? LocationProviderError, .privacyNotAccepted)
}
}
}