Skip to content

Commit

Permalink
review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
erenbesel committed Feb 14, 2025
1 parent 967c986 commit 0027e63
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public final class FormPhoneExtensionPickerItemView: FormItemView<FormPhoneExten
}

internal func setupView() {
var arrangedSubviews: [UIView] = []
let arrangedSubviews: [UIView]
if item.allowsSelection {
arrangedSubviews = [countryCodeLabel, chevronView, valueLabel]
} else {
Expand Down
6 changes: 5 additions & 1 deletion AdyenComponents/PayTo/PayToComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public final class PayToComponent: PaymentComponent,
private enum ViewIdentifier {
static let flowSelectionTitleLabelItem = "flowSelectionTitleLabel"
static let flowSelectionItem = "flowSelectionSegmentedControl"
static let phoneNumberItem = "phoneNumberItem"
static let continueButtonItem = "continueButton"
}

Expand Down Expand Up @@ -100,7 +101,10 @@ public final class PayToComponent: PaymentComponent,
localizationParameters: configuration.localizationParameters,
presenter: .init(self)
)
item.identifier = ViewIdentifierBuilder.build(scopeInstance: self, postfix: "phoneNumberItem")
item.identifier = ViewIdentifierBuilder.build(
scopeInstance: self,
postfix: ViewIdentifier.phoneNumberItem
)
return item
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ class FormItemViewBuilderTests: XCTestCase {
let view = item.build(with: FormItemViewBuilder())

XCTAssertNotNil(view as? FormPhoneExtensionPickerItemView)
XCTAssertFalse(item.allowsSelection)
}

func testPhoneExtensionMultiple() {
let presenter = UIViewController()
let query = PhoneExtensionsQuery(paymentMethod: .payTo)
let selectableValues = PhoneExtensionsRepository.get(with: query)
let item = FormPhoneExtensionPickerItem(
preselectedExtension: selectableValues[0],
selectableExtensions: selectableValues,
validationFailureMessage: nil,
style: .init(),
presenter: .init(presenter)
)
let view = item.build(with: FormItemViewBuilder())

XCTAssertNotNil(view as? FormPhoneExtensionPickerItemView)
XCTAssertTrue(item.allowsSelection)
}

func testViewBuildableFormTextItem() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PayToComponentTests: XCTestCase {
context: Dummy.context
)

setupRootViewController(sut.viewController)
sut.viewController.loadViewIfNeeded()

// Check by accessibility identifier
let flowSelectionTitleLabelItem = sut.viewController.view.findView(with: "AdyenComponents.PayToComponent.flowSelectionTitleLabel") as? UILabel
Expand All @@ -51,7 +51,7 @@ class PayToComponentTests: XCTestCase {
context: Dummy.context
)

setupRootViewController(sut.viewController)
sut.viewController.loadViewIfNeeded()

// Check by accessibility identifier
let flowSelectionItem = sut.viewController.view.findView(with: "AdyenComponents.PayToComponent.flowSelectionSegmentedControl") as? UISegmentedControl
Expand All @@ -68,7 +68,7 @@ class PayToComponentTests: XCTestCase {
context: Dummy.context
)

setupRootViewController(sut.viewController)
sut.viewController.loadViewIfNeeded()

// Check by accessibility identifier
let phoneNumberItem: FormPhoneNumberItemView = try XCTUnwrap(sut.viewController.view.findView(with: "AdyenComponents.PayToComponent.phoneNumberItem"))
Expand All @@ -84,7 +84,7 @@ class PayToComponentTests: XCTestCase {
context: Dummy.context
)

setupRootViewController(sut.viewController)
sut.viewController.loadViewIfNeeded()

// Check by accessibility identifier
let continueButton: FormButtonItemView = try XCTUnwrap(sut.viewController.view.findView(with: "AdyenComponents.PayToComponent.continueButton"))
Expand Down

0 comments on commit 0027e63

Please sign in to comment.