mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 20:05:19 +00:00
Merge branch 'main' into feature/ble-binary-transfers
# Conflicts: # bitchat/Views/ContentView.swift
This commit is contained in:
@@ -91,61 +91,3 @@ struct LocationNotesManagerTests {
|
||||
case shouldNotDerive
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
struct LocationNotesCounterTests {
|
||||
@Test func subscribeWithoutRelaysMarksUnavailable() {
|
||||
var subscribeCalled = false
|
||||
let deps = LocationNotesCounterDependencies(
|
||||
relayLookup: { _, _ in [] },
|
||||
subscribe: { _, _, _, _, _ in subscribeCalled = true },
|
||||
unsubscribe: { _ in }
|
||||
)
|
||||
|
||||
let counter = LocationNotesCounter(testDependencies: deps)
|
||||
counter.subscribe(geohash: "u4pruydq")
|
||||
|
||||
#expect(!subscribeCalled)
|
||||
#expect(!counter.relayAvailable)
|
||||
#expect(counter.initialLoadComplete)
|
||||
#expect(counter.count == 0)
|
||||
}
|
||||
|
||||
@Test func subscribeCountsUniqueNotes() {
|
||||
var storedHandler: ((NostrEvent) -> Void)?
|
||||
var storedEOSE: (() -> Void)?
|
||||
let deps = LocationNotesCounterDependencies(
|
||||
relayLookup: { _, _ in ["wss://relay.geo"] },
|
||||
subscribe: { filter, id, relays, handler, eose in
|
||||
#expect(relays == ["wss://relay.geo"])
|
||||
#expect(filter.kinds == [1])
|
||||
#expect(!id.isEmpty)
|
||||
storedHandler = handler
|
||||
storedEOSE = eose
|
||||
},
|
||||
unsubscribe: { _ in }
|
||||
)
|
||||
|
||||
let counter = LocationNotesCounter(testDependencies: deps)
|
||||
counter.subscribe(geohash: "u4pruydq")
|
||||
|
||||
var first = NostrEvent(
|
||||
pubkey: "pub",
|
||||
createdAt: Date(),
|
||||
kind: .textNote,
|
||||
tags: [["g", "u4pruydq"]],
|
||||
content: "a"
|
||||
)
|
||||
first.id = "eventA"
|
||||
storedHandler?(first)
|
||||
|
||||
let duplicate = first
|
||||
storedHandler?(duplicate)
|
||||
|
||||
storedEOSE?()
|
||||
|
||||
#expect(counter.relayAvailable)
|
||||
#expect(counter.count == 1)
|
||||
#expect(counter.initialLoadComplete)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user