Skip to content

Commit

Permalink
Update broken Twint tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nauaros committed Nov 21, 2024
1 parent ed1fadf commit fd7400b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ import Foundation
internal typealias HandlePayBlock = (
_ code: String,
_ appConfiguration: TWAppConfiguration,
_ callbackAppScheme: String
) -> Error?
_ callbackAppScheme: String,
_ completionHandler: @escaping ((any Error)?) -> Void
) -> Void

internal typealias HandleRegisterForUOF = (
_ code: String,
_ appConfiguration: TWAppConfiguration,
_ callbackAppScheme: String
) -> Error?
_ callbackAppScheme: String,
_ completionHandler: @escaping ((any Error)?) -> Void
) -> Void

internal typealias HandleControllerBlock = (
_ installedAppConfigurations: [TWAppConfiguration],
Expand Down Expand Up @@ -64,21 +66,23 @@ import Foundation
) {
handleFetchInstalledAppConfigurations(completion)
}

@objc override internal func pay(
withCode code: String,
appConfiguration: TWAppConfiguration,
callback callbackAppScheme: String
) -> Error? {
handlePay(code, appConfiguration, callbackAppScheme)
callback callbackAppScheme: String,
completionHandler: @escaping ((any Error)?) -> Void
) {
handlePay(code, appConfiguration, callbackAppScheme, completionHandler)
}

@objc override internal func registerForUOF(
withCode code: String,
appConfiguration: TWAppConfiguration,
callback: String
) -> Error? {
handleRegisterForUOF(code, appConfiguration, callback)
callback: String,
completionHandler: @escaping (Error?) -> Void
) {
handleRegisterForUOF(code, appConfiguration, callback, completionHandler)
}

@objc override internal func controller(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ import XCTest
let twintSpy = TwintSpy { configurationsBlock in
fetchBlockExpectation.fulfill()
configurationsBlock([.dummy])
} handlePay: { code, appConfiguration, callbackAppScheme in
} handlePay: { code, appConfiguration, callbackAppScheme, completionHandler in
payBlockExpectation.fulfill()
return nil
} handleRegisterForUOF: { _, _, _ in
completionHandler(nil)
} handleRegisterForUOF: { _, _, _, completionHandler in
XCTFail("RegisterForUOF should not have been called.")
return nil
completionHandler(nil)
} handleController: { installedAppConfigurations, selectionHandler, cancelHandler in
XCTFail("Twint controller should not have been shown")
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import XCTest
let twintSpy = TwintSpy { configurationsBlock in
fetchBlockExpectation.fulfill()
configurationsBlock([])
} handlePay: { code, appConfiguration, callbackAppScheme in
} handlePay: { code, appConfiguration, callbackAppScheme, completionHandler in
XCTFail("Pay should not have been called")
return nil
} handleRegisterForUOF: { _, _, _ in
completionHandler(nil)
} handleRegisterForUOF: { _, _, _, completionHandler in
XCTFail("RegisterForUOF should not have been called.")
return nil
completionHandler(nil)
} handleController: { installedAppConfigurations, selectionHandler, cancelHandler in
XCTFail("Twint controller should not have been shown")
return nil
Expand Down Expand Up @@ -86,16 +86,16 @@ import XCTest
let twintSpy = TwintSpy { configurationsBlock in
fetchBlockExpectation.fulfill()
configurationsBlock([.dummy])
} handlePay: { code, appConfiguration, callbackAppScheme in
} handlePay: { code, appConfiguration, callbackAppScheme, completionHandler in
payBlockExpectation.fulfill()
XCTAssertEqual(code, TwintSDKAction.dummy.sdkData.token)
XCTAssertEqual(appConfiguration.appDisplayName, TWAppConfiguration.dummy.appDisplayName)
XCTAssertEqual(appConfiguration.appURLScheme, TWAppConfiguration.dummy.appURLScheme)
XCTAssertEqual(callbackAppScheme, TwintSDKActionComponent.Configuration.dummy.callbackAppScheme)
return nil
} handleRegisterForUOF: { _, _, _ in
completionHandler(nil)
} handleRegisterForUOF: { _, _, _, completionHandler in
XCTFail("RegisterForUOF should not have been called.")
return nil
completionHandler(nil)
} handleController: { installedAppConfigurations, selectionHandler, cancelHandler in
XCTFail("Twint controller should not have been shown")
return nil
Expand Down Expand Up @@ -139,16 +139,16 @@ import XCTest
let twintSpy = TwintSpy { configurationsBlock in
fetchBlockExpectation.fulfill()
configurationsBlock(expectedAppConfigurations)
} handlePay: { code, appConfiguration, callbackAppScheme in
} handlePay: { code, appConfiguration, callbackAppScheme, completionHandler in
payBlockExpectation.fulfill()
XCTAssertEqual(code, TwintSDKAction.dummy.sdkData.token)
XCTAssertEqual(appConfiguration.appDisplayName, TWAppConfiguration.dummy.appDisplayName)
XCTAssertEqual(appConfiguration.appURLScheme, TWAppConfiguration.dummy.appURLScheme)
XCTAssertEqual(callbackAppScheme, TwintSDKActionComponent.Configuration.dummy.callbackAppScheme)
return nil
} handleRegisterForUOF: { _, _, _ in
completionHandler(nil)
} handleRegisterForUOF: { _, _, _, completionHandler in
XCTFail("RegisterForUOF should not have been called.")
return nil
completionHandler(nil)
} handleController: { installedAppConfigurations, selectionHandler, cancelHandler in
XCTAssertEqual(installedAppConfigurations, expectedAppConfigurations)
appSelectionHandler = selectionHandler
Expand Down Expand Up @@ -222,12 +222,13 @@ import XCTest
let twintSpy = TwintSpy { configurationsBlock in
fetchBlockExpectation.fulfill()
configurationsBlock([.dummy])
} handlePay: { code, appConfiguration, callbackAppScheme in
} handlePay: { code, appConfiguration, callbackAppScheme, completionHandler in
payBlockExpectation.fulfill()
return MockError(errorDescription: expectedAlertMessage)
} handleRegisterForUOF: { _, _, _ in
let error = MockError(errorDescription: expectedAlertMessage)
completionHandler(error)
} handleRegisterForUOF: { _, _, _, completionHandler in
XCTFail("RegisterForUOF should not have been called.")
return nil
completionHandler(nil)
} handleController: { installedAppConfigurations, selectionHandler, cancelHandler in
XCTFail("Twint controller should not have been shown")
return nil
Expand Down Expand Up @@ -270,16 +271,16 @@ import XCTest
let twintSpy = TwintSpy { configurationsBlock in
fetchBlockExpectation.fulfill()
configurationsBlock([.dummy])
} handlePay: { _, _, _ in
} handlePay: { _, _, _, completionHandler in
XCTFail("Pay should not have been called.")
return nil
} handleRegisterForUOF: { code, appConfiguration, callbackAppScheme in
completionHandler(nil)
} handleRegisterForUOF: { code, appConfiguration, callbackAppScheme, completionHandler in
registerForUFO.fulfill()
XCTAssertEqual(code, TwintSDKAction.dummy.sdkData.token)
XCTAssertEqual(appConfiguration.appDisplayName, TWAppConfiguration.dummy.appDisplayName)
XCTAssertEqual(appConfiguration.appURLScheme, TWAppConfiguration.dummy.appURLScheme)
XCTAssertEqual(callbackAppScheme, TwintSDKActionComponent.Configuration.dummy.callbackAppScheme)
return nil
completionHandler(nil)
} handleController: { installedAppConfigurations, selectionHandler, cancelHandler in
XCTFail("Twint controller should not have been shown")
return nil
Expand Down Expand Up @@ -327,16 +328,16 @@ import XCTest
let twintSpy = TwintSpy { configurationsBlock in
fetchBlockExpectation.fulfill()
configurationsBlock(expectedAppConfigurations)
} handlePay: { _, _, _ in
} handlePay: { _, _, _, completionHandler in
XCTFail("Pay should not have been called.")
return nil
} handleRegisterForUOF: { code, appConfiguration, callbackAppScheme in
completionHandler(nil)
} handleRegisterForUOF: { code, appConfiguration, callbackAppScheme, completionHandler in
registerForUFO.fulfill()
XCTAssertEqual(code, TwintSDKAction.dummy.sdkData.token)
XCTAssertEqual(appConfiguration.appDisplayName, TWAppConfiguration.dummy.appDisplayName)
XCTAssertEqual(appConfiguration.appURLScheme, TWAppConfiguration.dummy.appURLScheme)
XCTAssertEqual(callbackAppScheme, TwintSDKActionComponent.Configuration.dummy.callbackAppScheme)
return nil
completionHandler(nil)
} handleController: { installedAppConfigurations, selectionHandler, cancelHandler in
XCTAssertEqual(installedAppConfigurations, expectedAppConfigurations)
appSelectionHandler = selectionHandler
Expand Down

0 comments on commit fd7400b

Please sign in to comment.