From e08bbb15ca7371f8a8df0ea018c3ec6accc2f989 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Fri, 19 Apr 2024 22:05:30 +0100 Subject: [PATCH] HUC test fix --- .../Unit Tests/Modules/HUC_TokenizationViewModelTests.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Debug App/Tests/Unit Tests/Modules/HUC_TokenizationViewModelTests.swift b/Debug App/Tests/Unit Tests/Modules/HUC_TokenizationViewModelTests.swift index bc96c0e06f..ca114af536 100644 --- a/Debug App/Tests/Unit Tests/Modules/HUC_TokenizationViewModelTests.swift +++ b/Debug App/Tests/Unit Tests/Modules/HUC_TokenizationViewModelTests.swift @@ -21,6 +21,8 @@ final class HUC_TokenizationViewModelTests: XCTestCase { private var isImplementingPaymentMethodWithRequiredAction = false private var abortPayment = false + var onCreatePaymentWithData: ((PrimerCheckoutPaymentMethodData) -> Void)? + override func tearDown() { VaultService.apiClient = nil PrimerAPIConfigurationModule.apiClient = nil @@ -404,7 +406,8 @@ final class HUC_TokenizationViewModelTests: XCTestCase { } if self.abortPayment { - DispatchQueue.main.asyncAfter(deadline: .now() + 8) { + onCreatePaymentWithData = { _ in + print(self.eventsCalled) if isSurchargeIncluded { @@ -483,6 +486,7 @@ extension HUC_TokenizationViewModelTests: PrimerHeadlessUniversalCheckoutDelegat func primerHeadlessUniversalCheckoutWillCreatePaymentWithData(_ data: PrimerCheckoutPaymentMethodData, decisionHandler: @escaping (PrimerPaymentCreationDecision) -> Void) { eventsCalled.append("primerHeadlessUniversalCheckoutWillCreatePaymentWithData") + onCreatePaymentWithData?(data) if self.abortPayment { decisionHandler(.abortPaymentCreation())