Skip to content

Commit

Permalink
Merge pull request #258 from afterpay/feature/EIT-3043-remove-eu-assets
Browse files Browse the repository at this point in the history
EIT-3043 - Remove assets for EU
  • Loading branch information
ScottAntonacAP authored Aug 7, 2023
2 parents f196fbb + 9f5ebe9 commit f4b4ef0
Show file tree
Hide file tree
Showing 34 changed files with 45 additions and 228 deletions.
19 changes: 6 additions & 13 deletions AfterpayTests/CurrencyFormatterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import XCTest

class CurrencyFormatterTests: XCTestCase {
private let itIT = Locale(identifier: "it_IT")
private let frFR = Locale(identifier: "fr_FR")
private let esES = Locale(identifier: "es_ES")

func testEnAuLocale() {
let currencyFormatter = createCurrencyFormatters(clientLocale: Locales.enAU)
Expand All @@ -19,7 +22,6 @@ class CurrencyFormatterTests: XCTestCase {
XCTAssertEqual(currencyFormatter.gbp.string(from: 120), "£120.00")
XCTAssertEqual(currencyFormatter.nzd.string(from: 120), "$120.00 NZD")
XCTAssertEqual(currencyFormatter.usd.string(from: 120), "$120.00 USD")
XCTAssertEqual(currencyFormatter.eur.string(from: 120), "120.00€")
}

func testEnCaLocale() {
Expand All @@ -30,7 +32,6 @@ class CurrencyFormatterTests: XCTestCase {
XCTAssertEqual(currencyFormatter.gbp.string(from: 120), "£120.00")
XCTAssertEqual(currencyFormatter.nzd.string(from: 120), "$120.00 NZD")
XCTAssertEqual(currencyFormatter.usd.string(from: 120), "$120.00 USD")
XCTAssertEqual(currencyFormatter.eur.string(from: 120), "120.00€")
}

func testFrCaLocale() {
Expand All @@ -41,7 +42,6 @@ class CurrencyFormatterTests: XCTestCase {
XCTAssertEqual(currencyFormatter.gbp.string(from: 120), "£120,00")
XCTAssertEqual(currencyFormatter.nzd.string(from: 120), "$120,00 NZD")
XCTAssertEqual(currencyFormatter.usd.string(from: 120), "$120,00 USD")
XCTAssertEqual(currencyFormatter.eur.string(from: 120), "120,00€")
}

func testEnGbLocale() {
Expand All @@ -52,7 +52,6 @@ class CurrencyFormatterTests: XCTestCase {
XCTAssertEqual(currencyFormatter.gbp.string(from: 120), "£120.00")
XCTAssertEqual(currencyFormatter.nzd.string(from: 120), "$120.00 NZD")
XCTAssertEqual(currencyFormatter.usd.string(from: 120), "$120.00 USD")
XCTAssertEqual(currencyFormatter.eur.string(from: 120), "120.00€")
}

func testEnNzLocale() {
Expand All @@ -63,7 +62,6 @@ class CurrencyFormatterTests: XCTestCase {
XCTAssertEqual(currencyFormatter.gbp.string(from: 120), "£120.00")
XCTAssertEqual(currencyFormatter.nzd.string(from: 120), "$120.00")
XCTAssertEqual(currencyFormatter.usd.string(from: 120), "$120.00 USD")
XCTAssertEqual(currencyFormatter.eur.string(from: 120), "120.00€")
}

func testEnUSLocale() {
Expand All @@ -74,29 +72,26 @@ class CurrencyFormatterTests: XCTestCase {
XCTAssertEqual(currencyFormatter.gbp.string(from: 120), "£120.00")
XCTAssertEqual(currencyFormatter.nzd.string(from: 120), "NZ$120.00")
XCTAssertEqual(currencyFormatter.usd.string(from: 120), "$120.00")
XCTAssertEqual(currencyFormatter.eur.string(from: 120), "120.00€")
}

func testItItLocale() {
let currencyFormatter = createCurrencyFormatters(clientLocale: Locales.itIT)
let currencyFormatter = createCurrencyFormatters(clientLocale: itIT)

XCTAssertEqual(currencyFormatter.aud.string(from: 120), "$120,00 AUD")
XCTAssertEqual(currencyFormatter.cad.string(from: 120), "$120,00 CAD")
XCTAssertEqual(currencyFormatter.gbp.string(from: 120), "£120,00")
XCTAssertEqual(currencyFormatter.nzd.string(from: 120), "$120,00 NZD")
XCTAssertEqual(currencyFormatter.usd.string(from: 120), "$120,00 USD")
XCTAssertEqual(currencyFormatter.eur.string(from: 120), "120,00 €")
}

func testEsEsLocale() {
let currencyFormatter = createCurrencyFormatters(clientLocale: Locales.esES)
let currencyFormatter = createCurrencyFormatters(clientLocale: esES)

XCTAssertEqual(currencyFormatter.aud.string(from: 120), "$120,00 AUD")
XCTAssertEqual(currencyFormatter.cad.string(from: 120), "$120,00 CAD")
XCTAssertEqual(currencyFormatter.gbp.string(from: 120), "£120,00")
XCTAssertEqual(currencyFormatter.nzd.string(from: 120), "$120,00 NZD")
XCTAssertEqual(currencyFormatter.usd.string(from: 120), "$120,00 USD")
XCTAssertEqual(currencyFormatter.eur.string(from: 120), "120,00 €")
}

func createCurrencyFormatters(clientLocale: Locale) -> AllFormatters {
Expand All @@ -109,8 +104,7 @@ class CurrencyFormatterTests: XCTestCase {
cad: formatter(Locales.enCA),
gbp: formatter(Locales.enGB),
nzd: formatter(Locales.enNZ),
usd: formatter(Locales.enUS),
eur: formatter(Locales.esES)
usd: formatter(Locales.enUS)
)
}

Expand All @@ -120,7 +114,6 @@ class CurrencyFormatterTests: XCTestCase {
let gbp: CurrencyFormatter
let nzd: CurrencyFormatter
let usd: CurrencyFormatter
let eur: CurrencyFormatter
}

}
43 changes: 33 additions & 10 deletions AfterpayTests/LocaleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import XCTest
private struct LocaleCombination {
let merchantLocale: Locale
let consumerLocale: Locale
let valid: Bool
var valid: Bool?
}

class LocaleTests: XCTestCase {
Expand All @@ -24,9 +24,10 @@ class LocaleTests: XCTestCase {
let enAuLocale = Locale(identifier: "en_AU")
let enCaLocale = Locale(identifier: "en_CA")
let frCaLocale = Locale(identifier: "fr_CA")

let frFrLocale = Locale(identifier: "fr_FR")
let esEsLocale = Locale(identifier: "es_ES")

let itITLocale = Locale(identifier: "it_IT")
let esUsLocale = Locale(identifier: "es_US")
let jpJPLocale = Locale(identifier: "jp_JP")

Expand Down Expand Up @@ -57,14 +58,6 @@ class LocaleTests: XCTestCase {
LocaleCombination(merchantLocale: frCaLocale, consumerLocale: frCaLocale, valid: true),
LocaleCombination(merchantLocale: frCaLocale, consumerLocale: frFrLocale, valid: true),
LocaleCombination(merchantLocale: frCaLocale, consumerLocale: jpJPLocale, valid: false),

LocaleCombination(merchantLocale: frFrLocale, consumerLocale: frFrLocale, valid: true),
LocaleCombination(merchantLocale: frFrLocale, consumerLocale: enAuLocale, valid: true),
LocaleCombination(merchantLocale: frFrLocale, consumerLocale: esUsLocale, valid: false),
LocaleCombination(merchantLocale: frFrLocale, consumerLocale: esEsLocale, valid: false),
LocaleCombination(merchantLocale: frFrLocale, consumerLocale: frCaLocale, valid: true),
LocaleCombination(merchantLocale: frFrLocale, consumerLocale: enUsLocale, valid: true),
LocaleCombination(merchantLocale: frFrLocale, consumerLocale: jpJPLocale, valid: false),
]

for combination in localeCombinations {
Expand All @@ -87,4 +80,34 @@ class LocaleTests: XCTestCase {
)
}
}

func testInvalidMerchantLocaleCombinations() {
let invalidMerchantLocales: [LocaleCombination] = [
LocaleCombination(merchantLocale: frFrLocale, consumerLocale: frFrLocale),
LocaleCombination(merchantLocale: frFrLocale, consumerLocale: enAuLocale),
LocaleCombination(merchantLocale: frFrLocale, consumerLocale: esUsLocale),
LocaleCombination(merchantLocale: frFrLocale, consumerLocale: esEsLocale),
LocaleCombination(merchantLocale: frFrLocale, consumerLocale: frCaLocale),
LocaleCombination(merchantLocale: frFrLocale, consumerLocale: enUsLocale),
LocaleCombination(merchantLocale: frFrLocale, consumerLocale: jpJPLocale),

LocaleCombination(merchantLocale: esEsLocale, consumerLocale: esEsLocale),
LocaleCombination(merchantLocale: itITLocale, consumerLocale: itITLocale),
]

for combination in invalidMerchantLocales {
XCTAssertThrowsError(
try Configuration(
minimumAmount: one,
maximumAmount: oneThousand,
currencyCode: usdCode,
locale: combination.merchantLocale,
environment: .sandbox,
consumerLocale: combination.consumerLocale
)
) { error in
XCTAssertEqual(error as? ConfigurationError, .invalidLocale(combination.merchantLocale))
}
}
}
}
6 changes: 3 additions & 3 deletions AfterpayTests/PriceBreakdownTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ class PriceBreakdownTests: XCTestCase {

let fiftyDollarBreakdown = PriceBreakdown(totalAmount: 50)
XCTAssertEqual(fiftyDollarBreakdown.badgePlacement, .end)
XCTAssertEqual(fiftyDollarBreakdown.string, "or 3 interest-free payments of 16.67€ with")
XCTAssertEqual(fiftyDollarBreakdown.string, "or pay with")

let oneHundredDollarBreakdown = PriceBreakdown(totalAmount: 100)
XCTAssertEqual(oneHundredDollarBreakdown.badgePlacement, .end)
XCTAssertEqual(oneHundredDollarBreakdown.string, "or 3 interest-free payments of 33.33€ with")
XCTAssertEqual(oneHundredDollarBreakdown.string, "or pay with")

let twoHundredDollarBreakdown = PriceBreakdown(totalAmount: 200)
XCTAssertEqual(twoHundredDollarBreakdown.badgePlacement, .end)
XCTAssertEqual(twoHundredDollarBreakdown.string, "or 3 interest-free payments of 66.67€ with")
XCTAssertEqual(twoHundredDollarBreakdown.string, "or pay with")
}

func testOutOfRangeWithMinimum() {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Afterpay/Afterpay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ internal var brand: Brand {
}

public var enabled: Bool {
language != nil
return language != nil && getConfiguration()?.locale != nil
}

public var cashAppClientId: String? {
Expand Down
3 changes: 0 additions & 3 deletions Sources/Afterpay/Model/Brand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import Foundation

private let clearpayLocales: Set<Locale> = [
Locales.enGB,
Locales.esES,
Locales.frFR,
Locales.itIT,
]
private let afterpayLocales: Set<Locale> = [
Locales.enAU,
Expand Down
9 changes: 1 addition & 8 deletions Sources/Afterpay/Model/CurrencyFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,8 @@ struct CurrencyFormatter {

let usCurrencySymbol = Locales.enUS.currencySymbol
let gbCurrencySymbol = Locales.enGB.currencySymbol
let euCurrencySymbol = Locales.frFR.currencySymbol

if clientLocale == Locales.enUS {
if currencySymbol == euCurrencySymbol {
formatter.positiveFormat = "#,##0.00¤"
}
} else if clientLocale.currencyCode != locale.currencyCode {
if clientLocale != Locales.enUS && clientLocale.currencyCode != locale.currencyCode {
formatter.currencySymbol = currencySymbol

switch currencySymbol {
Expand All @@ -55,8 +50,6 @@ struct CurrencyFormatter {
formatter.positiveFormat = "¤#,##0.00 ¤¤"
case gbCurrencySymbol:
formatter.positiveFormat = "¤#,##0.00"
case euCurrencySymbol:
formatter.positiveFormat = "#,##0.00¤"
default:
formatter.positiveFormat = formatter.positiveFormat
}
Expand Down
9 changes: 0 additions & 9 deletions Sources/Afterpay/Model/Locales.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ enum Locales: Hashable {
static let enGB = Locale(identifier: "en_GB")
static let enNZ = Locale(identifier: "en_NZ")
static let enUS = Locale(identifier: "en_US")
static let frFR = Locale(identifier: "fr_FR")
static let itIT = Locale(identifier: "it_IT")
static let esES = Locale(identifier: "es_ES")
static let enUSposix = Locale(identifier: "en_US_POSIX")

static let validArray: [Locale] = [
Expand All @@ -28,9 +25,6 @@ enum Locales: Hashable {
enGB,
enNZ,
enUS,
frFR,
itIT,
esES,
]
}

Expand All @@ -40,9 +34,6 @@ private let validRegionLanguages = [
Locales.enGB.regionCode!: [Locales.enGB],
Locales.enNZ.regionCode!: [Locales.enNZ],
Locales.enUS.regionCode!: [Locales.enUS],
Locales.frFR.regionCode!: [Locales.frFR, Locales.enGB],
Locales.itIT.regionCode!: [Locales.itIT, Locales.enGB],
Locales.esES.regionCode!: [Locales.esES, Locales.enGB],
]

internal func getRegionLanguage(merchantLocale: Locale, clientLocale: Locale) -> Locale? {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Afterpay/Model/PriceBreakdown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ struct PriceBreakdown {
}

internal func getNumberOfInstalments(currencyCode: String?) -> Decimal {
return currencyCode == "EUR" && currencyCode != nil ? 3 : 4
return 4
}

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Loading

0 comments on commit f4b4ef0

Please sign in to comment.