Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore Adding QRCodeAction + DocumentAction tests #1514

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ class AdyenActionComponentTests: XCTestCase {
"type" : "voucher"
}
"""

let qrAction = """
{
"paymentMethodType": "upi_qr",
"qrCodeData": "QR_CODE_DATA",
"paymentData": ""
}
"""

let documentAction = """
{
"paymentMethodType": "directdebit_GB",
"url": "https://adyen.com"
}
"""

func testRedirectToHttpWebLink() throws {
let sut = AdyenActionComponent(context: Dummy.context)
Expand Down Expand Up @@ -118,13 +133,7 @@ class AdyenActionComponentTests: XCTestCase {
let action = try! JSONDecoder().decode(ThreeDS2Action.self, from: threeDSFingerprintAction.data(using: .utf8)!)
sut.handle(Action.threeDS2(action))

let waitExpectation = expectation(description: "Expect in app browser to be presented and then dismissed")
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .seconds(2)) {
XCTAssertNotNil(sut.currentActionComponent as? ThreeDS2Component)
waitExpectation.fulfill()
}

waitForExpectations(timeout: 10, handler: nil)
wait { sut.currentActionComponent is ThreeDS2Component }
}

func testVoucherAction() throws {
Expand All @@ -146,4 +155,27 @@ class AdyenActionComponentTests: XCTestCase {

waitForExpectations(timeout: 100, handler: nil)
}

func testQRCodeAction() throws {

let sut = AdyenActionComponent(context: Dummy.context)
sut.presentationDelegate = try UIViewController.topPresenter()

let action = try! JSONDecoder().decode(QRCodeAction.self, from: qrAction.data(using: .utf8)!)
sut.handle(Action.qrCode(action))

try waitUntilTopPresenter(isOfType: QRCodeViewController.self)
}

func testDocumentAction() throws {
// DocumentAction
let sut = AdyenActionComponent(context: Dummy.context)
sut.presentationDelegate = try UIViewController.topPresenter()

let action = try! JSONDecoder().decode(DocumentAction.self, from: documentAction.data(using: .utf8)!)
sut.handle(Action.document(action))

let documentViewController = try waitUntilTopPresenter(isOfType: ADYViewController.self)
XCTAssertNotNil(documentViewController.view as? DocumentActionView)
}
}
Loading