Skip to content

Commit

Permalink
Add screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe committed Nov 21, 2024
1 parent c830228 commit ec94824
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,30 @@ class PaymentMethodRowButtonSnapshotTests: STPSnapshotTestCase {
rowButton.state = .selected
verify(rowButton)
}

func testPaymentMethodRowButton_newPaymentMethod_unselected() {
let rowButton = RowButton.makeForPaymentMethodType(
paymentMethodType: .instantDebits,
promoText: nil,
savedPaymentMethodType: nil,
appearance: .default,
shouldAnimateOnPress: false,
didTap: { _ in }
)
verify(rowButton)
}

func testPaymentMethodRowButton_newPaymentMethod_withPromo_unselected() {
let rowButton = RowButton.makeForPaymentMethodType(
paymentMethodType: .instantDebits,
promoText: "$5",
savedPaymentMethodType: nil,
appearance: .default,
shouldAnimateOnPress: false,
didTap: { _ in }
)
verify(rowButton)
}

func verify(
_ view: UIView,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// PaymentMethodTypeCollectionViewCellSnapshotTests.swift
// StripePaymentSheetTests
//
// Created by Till Hellmund on 11/21/24.
//

import Foundation
import StripeCoreTestUtils
import UIKit

@testable@_spi(STP) import StripePaymentSheet

class PaymentMethodTypeCollectionViewCellSnapshotTests: STPSnapshotTestCase {

func test_withPromoBadge() {
let cell = PaymentMethodTypeCollectionView.PaymentTypeCell()
cell.paymentMethodType = .instantDebits
cell.promoBadgeText = "$5"
verify(cell)
}

func verify(
_ cell: UICollectionViewCell,
identifier: String? = nil,
file: StaticString = #filePath,
line: UInt = #line
) {
let view = CellWrapperView(
cell: cell,
size: CGSize(width: 120, height: PaymentMethodTypeCollectionView.cellHeight)
)
STPSnapshotVerifyView(view, identifier: identifier, file: file, line: line)
}
}

private class CellWrapperView: UIView {
init(cell: UICollectionViewCell, size: CGSize) {
super.init(frame: CGRect(origin: .zero, size: size))
cell.frame = self.bounds
addSubview(cell)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Binary file added ...ttonSnapshotTests/[email protected]
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 ec94824

Please sign in to comment.