Skip to content

Commit

Permalink
fix unit tests again
Browse files Browse the repository at this point in the history
  • Loading branch information
charliecruzan-stripe committed Jan 6, 2023
1 parent f7890f8 commit 0822446
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ios/Tests/ApplePayUtilsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ApplePayUtilsTests: XCTestCase {

func test_buildPaymentSheetApplePayConfig_FailsWithoutMerchantIdentifier() throws {
XCTAssertThrowsError(
try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: nil, merchantCountryCode: "", paymentSummaryItems: nil, buttonType: nil)
try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: nil, merchantCountryCode: "", paymentSummaryItems: nil, buttonType: nil, customHandlers: nil)
) { error in
XCTAssertEqual(
error as! ApplePayUtilsError, ApplePayUtilsError.missingMerchantId
Expand All @@ -25,7 +25,7 @@ class ApplePayUtilsTests: XCTestCase {

func test_buildPaymentSheetApplePayConfig_FailsWithoutCountryCode() throws {
XCTAssertThrowsError(
try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: nil, paymentSummaryItems: nil, buttonType: nil)
try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: nil, paymentSummaryItems: nil, buttonType: nil, customHandlers: nil)
) { error in
XCTAssertEqual(
error as! ApplePayUtilsError, ApplePayUtilsError.missingCountryCode
Expand All @@ -34,13 +34,13 @@ class ApplePayUtilsTests: XCTestCase {
}

func test_buildPaymentSheetApplePayConfig_withNilAndEmptyArray_shouldBeEqual() throws {
let resultWithItemsAsNil = try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: TestFixtures.COUNTRY_CODE, paymentSummaryItems: nil, buttonType: nil)
let resultWithItemsAsEmptyArray = try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: TestFixtures.COUNTRY_CODE, paymentSummaryItems: [], buttonType: nil)
let resultWithItemsAsNil = try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: TestFixtures.COUNTRY_CODE, paymentSummaryItems: nil, buttonType: nil, customHandlers: nil)
let resultWithItemsAsEmptyArray = try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: TestFixtures.COUNTRY_CODE, paymentSummaryItems: [], buttonType: nil, customHandlers: nil)
XCTAssertEqual(resultWithItemsAsNil.paymentSummaryItems, resultWithItemsAsEmptyArray.paymentSummaryItems)
}

func test_buildPaymentSheetApplePayConfig_withItems_shouldMatchExpected() throws {
let result = try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: TestFixtures.COUNTRY_CODE, paymentSummaryItems: TestFixtures.CART_ITEM_DICTIONARY, buttonType: nil)
let result = try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: TestFixtures.COUNTRY_CODE, paymentSummaryItems: TestFixtures.CART_ITEM_DICTIONARY, buttonType: nil, customHandlers: nil)

let deferredItemResult = PKDeferredPaymentSummaryItem(label: "deferred label", amount: 1.00)
deferredItemResult.deferredDate = Date(timeIntervalSince1970: 123456789)
Expand Down Expand Up @@ -178,12 +178,12 @@ class ApplePayUtilsTests: XCTestCase {
}

func test_buildPaymentSheetApplePayConfig_withNilButtonType_shouldBePlain() throws {
let result = try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: TestFixtures.COUNTRY_CODE, paymentSummaryItems: nil, buttonType: nil)
let result = try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: TestFixtures.COUNTRY_CODE, paymentSummaryItems: nil, buttonType: nil, customHandlers: nil)
XCTAssertEqual(result.buttonType, .plain)
}

func test_buildPaymentSheetApplePayConfig_withButtonType4_shouldBeDonate() throws {
let result = try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: TestFixtures.COUNTRY_CODE, paymentSummaryItems: nil, buttonType: 4)
let result = try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: TestFixtures.COUNTRY_CODE, paymentSummaryItems: nil, buttonType: 4, customHandlers: nil)
XCTAssertEqual(result.buttonType, .donate)
}

Expand Down

0 comments on commit 0822446

Please sign in to comment.