mirror of
https://github.com/sudosylabs/vnidrop.git
synced 2026-08-05 10:29:58 +02:00
test(apple): CoreGateway seam, XCTest suite, and CI
- Introduce a CoreGateway protocol so feature models depend on a seam (CoreRepository conforms); enables faking the core in tests - Add a VniDropTests target with 42 tests mirroring the KMP suites: approval coordinator, send/receive/settings/app models, preferences, file previews, invitation decode, message queue, error mapping - Add a fake gateway/file-system/device-info and fixtures - Add .github/workflows/apple.yml: build the Rust core, generate the project, and run the tests on an iOS Simulator
This commit is contained in:
58
apple/Tests/SendModelTests.swift
Normal file
58
apple/Tests/SendModelTests.swift
Normal file
@@ -0,0 +1,58 @@
|
||||
import XCTest
|
||||
@testable import VniDrop
|
||||
|
||||
/// Ports the send-side state-machine assertions from `feature/ViewModelsTest.kt`.
|
||||
@MainActor
|
||||
final class SendModelTests: XCTestCase {
|
||||
|
||||
private func makeModel(_ core: FakeCoreGateway) -> SendModel {
|
||||
SendModel(
|
||||
repository: core,
|
||||
fileSystemService: FakeFileSystemService(),
|
||||
preferences: Fixtures.preferences(),
|
||||
filePreviewRepository: FilePreviewRepository(appDataDir: NSTemporaryDirectory() + UUID().uuidString),
|
||||
messages: UiMessageController()
|
||||
)
|
||||
}
|
||||
|
||||
func testOpenAndCloseTransferDetails() {
|
||||
let model = makeModel(FakeCoreGateway())
|
||||
model.openTransfer(3)
|
||||
XCTAssertEqual(model.state.selectedTransferId, 3)
|
||||
model.closeTransferDetails()
|
||||
XCTAssertNil(model.state.selectedTransferId)
|
||||
}
|
||||
|
||||
func testDeleteTransferConfirmationFlow() async {
|
||||
let core = FakeCoreGateway()
|
||||
let model = makeModel(core)
|
||||
model.openTransfer(3)
|
||||
|
||||
model.requestDeleteTransfer()
|
||||
XCTAssertTrue(model.state.isDeleteConfirmationOpen)
|
||||
|
||||
model.confirmDeleteTransfer()
|
||||
await waitUntil { core.deletedTransfers.contains(3) }
|
||||
XCTAssertEqual(core.deletedTransfers, [3])
|
||||
XCTAssertNil(model.state.selectedTransferId)
|
||||
XCTAssertFalse(model.state.isDeleteConfirmationOpen)
|
||||
}
|
||||
|
||||
func testStopSharingCancelsTheTransfer() async {
|
||||
let core = FakeCoreGateway()
|
||||
let model = makeModel(core)
|
||||
model.stopSharing(transferId: 4)
|
||||
await waitUntil { core.cancelledTransfers.contains(4) }
|
||||
XCTAssertEqual(core.cancelledTransfers, [4])
|
||||
}
|
||||
|
||||
func testCancelReceiverRefusesTheRequest() async {
|
||||
let core = FakeCoreGateway()
|
||||
let model = makeModel(core)
|
||||
model.openTransfer(1)
|
||||
model.cancelReceiver(requestId: "req-1")
|
||||
await waitUntil { core.responses.contains { $0.id == "req-1" } }
|
||||
let response = core.responses.first { $0.id == "req-1" }
|
||||
XCTAssertEqual(response?.accepted, false)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user