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 7b7570f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
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 7b7570f

Please sign in to comment.