From 83adb46b33cfd2599ab3d4575437289c8888c81e Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 24 Mar 2026 11:51:51 +0100 Subject: [PATCH] add test for voice call --- .../Sources/ElementCallServiceTests.swift | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/UnitTests/Sources/ElementCallServiceTests.swift b/UnitTests/Sources/ElementCallServiceTests.swift index 9e2e5b59e..14d910f53 100644 --- a/UnitTests/Sources/ElementCallServiceTests.swift +++ b/UnitTests/Sources/ElementCallServiceTests.swift @@ -49,6 +49,34 @@ final class ElementCallServiceTests { } #expect(callProvider.reportNewIncomingCallWithUpdateCompletionCalled) + // Verify the provider was called with a CXCallUpdate that has video enabled + if let args = callProvider.reportNewIncomingCallWithUpdateCompletionReceivedArguments { + #expect(args.update.hasVideo == true) + } else { + Issue.record("Expected reportNewIncomingCallWithUpdateCompletionReceivedArguments to be captured") + } + } + + @Test + func incomingVoiceCall() async { + #expect(!callProvider.reportNewIncomingCallWithUpdateCompletionCalled) + + await confirmation { confirmation in + let pkPushPayloadMock = PKPushPayloadMock().updatingExpiration(currentDate, lifetime: 30) + .updateIsVoice(true) + + service.pushRegistry(pushRegistry, didReceiveIncomingPushWith: pkPushPayloadMock, for: .voIP) { + confirmation() + } + } + + #expect(callProvider.reportNewIncomingCallWithUpdateCompletionCalled) + // Verify the provider was called with a CXCallUpdate that has video enabled + if let args = callProvider.reportNewIncomingCallWithUpdateCompletionReceivedArguments { + #expect(args.update.hasVideo == false) + } else { + Issue.record("Expected reportNewIncomingCallWithUpdateCompletionReceivedArguments to be captured") + } } @Test @@ -138,4 +166,9 @@ private class PKPushPayloadMock: PKPushPayload { dict[ElementCallServiceNotificationKey.expirationDate.rawValue] = from.addingTimeInterval(lifetime) return self } + + func updateIsVoice(_ isVoice: Bool) -> Self { + dict[ElementCallServiceNotificationKey.isVoiceCall.rawValue] = isVoice + return self + } }