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 Improve tintColor tests #1507

Merged
merged 9 commits into from
Jan 18, 2024
Merged
Changes from 1 commit
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
19 changes: 12 additions & 7 deletions Tests/Card Tests/CardComponentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,12 @@ class CardComponentTests: XCTestCase {

var configuration = CardComponent.Configuration()

let tintColor: UIColor = .black
let titleColor: UIColor = .gray

configuration.style = {
var style = FormComponentStyle(tintColor: .systemYellow)
style.textField.title.color = .gray
var style = FormComponentStyle(tintColor: tintColor)
style.textField.title.color = titleColor
return style
}()

Expand All @@ -425,13 +428,14 @@ class CardComponentTests: XCTestCase {
let switchView: UISwitch = try XCTUnwrap(component.viewController.view.findView(with: "AdyenCard.CardComponent.storeDetailsItem.switch"))
let securityCodeItemView: FormTextItemView<FormCardSecurityCodeItem> = try XCTUnwrap(component.viewController.view.findView(with: "AdyenCard.CardComponent.securityCodeItem"))

XCTAssertEqual(securityCodeItemView.titleLabel.textColor, .gray)
wait(until: switchView, at: \.onTintColor, is: tintColor)

wait(until: securityCodeItemView, at: \.titleLabel.textColor, is: titleColor)

self.focus(textItemView: securityCodeItemView)
focus(textItemView: securityCodeItemView)

wait(until: switchView, at: \.onTintColor, is: .systemYellow)
wait(until: securityCodeItemView, at: \.titleLabel.textColor, is: .systemYellow)
wait(until: securityCodeItemView, at: \.separatorView.backgroundColor?.cgColor, is: UIColor.systemYellow.cgColor)
wait(until: securityCodeItemView, at: \.titleLabel.textColor, is: tintColor)
wait(until: securityCodeItemView, at: \.separatorView.backgroundColor, is: tintColor)
}

func testSuccessTintColorCustomization() throws {
Expand Down Expand Up @@ -2213,6 +2217,7 @@ class CardComponentTests: XCTestCase {

private func focus(textItemView: some FormTextItemView<some FormTextItem>) {
textItemView.textField.becomeFirstResponder()
wait(until: textItemView.textField, at: \.isFirstResponder, is: true)
}

private enum CardViewIdentifier {
Expand Down
Loading