migration
This commit is contained in:
47
PediFoodsTests/GuestLocationStoreTests.swift
Normal file
47
PediFoodsTests/GuestLocationStoreTests.swift
Normal file
@@ -0,0 +1,47 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import PediFoods
|
||||
|
||||
/// `GuestLocationStore.shared` is a singleton backed by the real Keychain
|
||||
/// under fixed key names - concurrent tests touching the same keys would
|
||||
/// stomp on each other, so this suite runs serialized. Every test cleans
|
||||
/// up after itself via the store's own clear/nil-set APIs.
|
||||
@Suite(.serialized)
|
||||
struct GuestLocationStoreTests {
|
||||
@Test("deviceId is stable across repeated reads")
|
||||
func deviceIdIsStableAcrossReads() {
|
||||
let first = GuestLocationStore.shared.deviceId
|
||||
let second = GuestLocationStore.shared.deviceId
|
||||
#expect(first == second)
|
||||
#expect(first.isEmpty == false)
|
||||
}
|
||||
|
||||
@Test("selectedState/selectedCity round-trip and clear together via clearSelectedLocation")
|
||||
func selectedStateAndCityRoundTripAndClear() {
|
||||
GuestLocationStore.shared.selectedState = "SP"
|
||||
GuestLocationStore.shared.selectedCity = "São Paulo"
|
||||
#expect(GuestLocationStore.shared.selectedState == "SP")
|
||||
#expect(GuestLocationStore.shared.selectedCity == "São Paulo")
|
||||
|
||||
GuestLocationStore.shared.clearSelectedLocation()
|
||||
#expect(GuestLocationStore.shared.selectedState == nil)
|
||||
#expect(GuestLocationStore.shared.selectedCity == nil)
|
||||
}
|
||||
|
||||
@Test("appAttestKeyId round-trips and clears when set to nil")
|
||||
func appAttestKeyIdRoundTripAndClear() {
|
||||
GuestLocationStore.shared.appAttestKeyId = "key-123"
|
||||
#expect(GuestLocationStore.shared.appAttestKeyId == "key-123")
|
||||
|
||||
GuestLocationStore.shared.appAttestKeyId = nil
|
||||
#expect(GuestLocationStore.shared.appAttestKeyId == nil)
|
||||
}
|
||||
|
||||
@Test("attestationPlaceholder is stable across repeated reads")
|
||||
func attestationPlaceholderIsStableAcrossReads() {
|
||||
let first = GuestLocationStore.shared.attestationPlaceholder
|
||||
let second = GuestLocationStore.shared.attestationPlaceholder
|
||||
#expect(first == second)
|
||||
#expect(first.isEmpty == false)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user