LocalData/Tests/LocalDataTests/SyncDelegateTests.swift
Matt Bruce 74ec1a8666 Update Helpers and tests
Summary:
- Sources: update Helpers
- Tests: update tests for AppGroupTests.swift, RouterDomainTests.swift, RouterSecurityTests.swift (+1 more)

Stats:
- 5 files changed, 283 insertions(+), 2 deletions(-)
2026-01-18 13:43:10 -06:00

44 lines
1.4 KiB
Swift

import Foundation
import Testing
import WatchConnectivity
@testable import LocalData
@Suite struct SyncDelegateTests {
@Test func delegateProxyActivationCallbacks() {
let proxy = SessionDelegateProxy.shared
let session = WCSession.default
// Exercise activation completion (success)
proxy.session(session, activationDidCompleteWith: .activated, error: nil)
// Exercise activation completion (error)
let error = NSError(domain: "test", code: 1, userInfo: nil)
proxy.session(session, activationDidCompleteWith: .notActivated, error: error)
}
@Test func delegateProxyContextReceived() async throws {
let proxy = SessionDelegateProxy.shared
let session = WCSession.default
let context: [String: Any] = [
"test.sync.key": Data("sync-data".utf8)
]
// This triggers SyncHelper.handleReceivedContext
proxy.session(session, didReceiveApplicationContext: context)
// Wait a bit for the Task to start/finish
try await Task.sleep(for: .milliseconds(100))
}
#if os(iOS)
@Test func delegateProxyiOSCallbacks() {
let proxy = SessionDelegateProxy.shared
let session = WCSession.default
proxy.sessionDidBecomeInactive(session)
proxy.sessionDidDeactivate(session)
}
#endif
}