Skip to content

Commit

Permalink
Add snapshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe committed Dec 17, 2024
1 parent 88dfa42 commit 7d44df9
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ re-entering the security code (CVV/CVC). */
/* Disclaimer for when a promotion is available for paying with a bank account. e.g. 'Get $5 back when […]' */
"Get %@ back when you pay with your bank. <terms>See terms</terms>" = "Get %@ back when you pay with your bank. <terms>See terms</terms>";

/* Label for when the user is not eligible for a promo. e.g. 'No $5 promo' */
"No %@ promo" = "No %@ promo";

/* Bacs Debit mandate text */
"I understand that Stripe will be collecting Direct Debits on behalf of %@ and confirm that I am the account holder and the only person required to authorise debits from this account." = "I understand that Stripe will be collecting Direct Debits on behalf of %@ and confirm that I am the account holder and the only person required to authorise debits from this account.";

Expand Down Expand Up @@ -215,6 +212,9 @@ re-entering the security code (CVV/CVC). */
/* Title shown above a section containing payment methods that a customer can choose to pay with e.g. card, bank account, etc. */
"New payment method" = "New payment method";

/* Label for when the user is not eligible for a promo. */
"No %@ promo" = "No %@ promo";

/* Text of a label for confirming an email address. E.g., 'Not [email protected]?' */
"Not %@?" = "Not %@?";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// BankAccountInfoViewSnapshotTests.swift
// StripePaymentSheetTests
//
// Created by Till Hellmund on 12/17/24.
//

import StripeCoreTestUtils
import UIKit
@testable import StripePaymentSheet

final class BankAccountInfoViewSnapshotTests : STPSnapshotTestCase {

private static let frame = CGRect(x: 0, y: 0, width: 320, height: 1000)

func test_noPromoBadge() {
let view = BankAccountInfoView(
frame: Self.frame,
theme: .default,
incentive: nil
)
view.setBankName(text: "Stripe Bank")
view.setLastFourOfBank(text: "•••• 4242")
view.setIncentiveEligible(false)

verify(view)
}

func test_eligibleForPromo() {
let view = BankAccountInfoView(
frame: Self.frame,
theme: .default,
incentive: .init(identifier: "link_instant_debits", displayText: "$5")
)
view.setBankName(text: "Stripe Bank")
view.setLastFourOfBank(text: "•••• 4242")
view.setIncentiveEligible(true)

verify(view)
}

func test_ineligibleForPromo() {
let view = BankAccountInfoView(
frame: Self.frame,
theme: .default,
incentive: .init(identifier: "link_instant_debits", displayText: "$5")
)
view.setBankName(text: "Stripe Bank")
view.setLastFourOfBank(text: "•••• 4242")
view.setIncentiveEligible(false)

verify(view)
}

private func verify(
_ view: UIView,
identifier: String? = nil,
file: StaticString = #filePath,
line: UInt = #line
) {
view.backgroundColor = .white
view.autosizeHeight(width: 300)
STPSnapshotVerifyView(view, identifier: identifier, file: file, line: line)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7d44df9

Please sign in to comment.