mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-24 21:45:20 +00:00
* SwiftTesting: NoiseProtocolTests + BinaryProtocolPaddingTests * SwiftTesting: `NotificationStreamAssemblerTests` * SwiftTesting: `NostrProtocolTests` * SwiftTesting: `BinaryProtocolTests` * SwiftTesting: `PeerIDTests` * SwiftTesting: `BLEServiceTests` * SwiftTesting: `CommandProcessorTests` * SwiftTesting: `GCSFilterTests` * SwiftTesting: `GeohashBookmarksStoreTests` * Remove `peerID` test constants * Remove PeerID + String interop from tests * Refactor IntegrationTests to extract state management * Refactor global state management of MockBLEService * NoiseProtocolSwiftTests: `actor` -> `struct` * Remove measurement tests w/ no benchmark * `NoiseProtocolSwiftTests` -> `NoiseProtocolTests` * SwiftTesting: `LocationChannelsTests` * SwiftTesting: `GossipSyncManagerTests` * SwiftTesting: `LocationNotesManagerTests` * Global `sleep` function for tests * SwiftTesting: `IntegrationTests` --------- Co-authored-by: jack <jackjackbits@users.noreply.github.com>
39 lines
1.2 KiB
Swift
39 lines
1.2 KiB
Swift
import Testing
|
|
import Foundation
|
|
@testable import bitchat
|
|
|
|
struct GeohashBookmarksStoreTests {
|
|
private let storeKey = "locationChannel.bookmarks"
|
|
private let storage = UserDefaults(suiteName: UUID().uuidString)!
|
|
private let store: GeohashBookmarksStore
|
|
|
|
init() {
|
|
store = GeohashBookmarksStore(storage: storage)
|
|
}
|
|
|
|
@Test func toggleAndNormalize() {
|
|
// Start clean
|
|
#expect(store.bookmarks.isEmpty)
|
|
|
|
// Add with mixed case and hash prefix
|
|
store.toggle("#U4PRUY")
|
|
#expect(store.isBookmarked("u4pruy"))
|
|
#expect(store.bookmarks.first == "u4pruy")
|
|
|
|
// Toggling again removes
|
|
store.toggle("u4pruy")
|
|
#expect(!store.isBookmarked("u4pruy"))
|
|
#expect(store.bookmarks.isEmpty)
|
|
}
|
|
|
|
@Test func persistenceWritten() throws {
|
|
store.toggle("ezs42")
|
|
store.toggle("u4pruy")
|
|
// Verify persisted JSON contains both (order not enforced here)
|
|
let data = try #require(storage.data(forKey: storeKey), "No persisted data found")
|
|
let arr = try JSONDecoder().decode([String].self, from: data)
|
|
#expect(arr.contains("ezs42"))
|
|
#expect(arr.contains("u4pruy"))
|
|
}
|
|
}
|