mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 04:45:20 +00:00
Extract BLE and chat architecture policies (#1324)
Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import CoreBluetooth
|
||||
import Testing
|
||||
@testable import bitchat
|
||||
|
||||
struct ChatBluetoothAlertPolicyTests {
|
||||
@Test
|
||||
func poweredOffShowsAlertMessage() {
|
||||
let update = ChatBluetoothAlertPolicy.update(for: .poweredOff)
|
||||
|
||||
#expect(update.isPresented)
|
||||
#expect(update.message?.isEmpty == false)
|
||||
}
|
||||
|
||||
@Test
|
||||
func unauthorizedShowsAlertMessage() {
|
||||
let update = ChatBluetoothAlertPolicy.update(for: .unauthorized)
|
||||
|
||||
#expect(update.isPresented)
|
||||
#expect(update.message?.isEmpty == false)
|
||||
}
|
||||
|
||||
@Test
|
||||
func poweredOnHidesAndClearsAlertMessage() {
|
||||
let update = ChatBluetoothAlertPolicy.update(for: .poweredOn)
|
||||
|
||||
#expect(!update.isPresented)
|
||||
#expect(update.message == "")
|
||||
}
|
||||
|
||||
@Test
|
||||
func transientStatesHideWithoutChangingAlertMessage() {
|
||||
let unknown = ChatBluetoothAlertPolicy.update(for: .unknown)
|
||||
let resetting = ChatBluetoothAlertPolicy.update(for: .resetting)
|
||||
|
||||
#expect(!unknown.isPresented)
|
||||
#expect(unknown.message == nil)
|
||||
#expect(!resetting.isPresented)
|
||||
#expect(resetting.message == nil)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user