将会话、权限、位置、收款与排队存储拆分为独立模块,同步更新各 ViewModel 与单元测试,并补充素材管理 UI 与个人空间设置交互。 Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
1.6 KiB
Swift
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)
|
|
}
|
|
}
|
|
}
|