Skip to content

Commit 844525f

Browse files
committed
Fix errors and warnings. Builds, but tests will still fail.
1 parent 2c82d97 commit 844525f

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

WooCommerce/Classes/Tools/Currency/MoneyFormatter.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ extension MoneyFormatter {
117117
return stringResult
118118
}
119119

120+
/// Returns a string that displays the amount using all of the specified currency settings
121+
/// - Parameters:
122+
/// - localizedAmount: a formatted string returned from `localizeAmount()`
123+
/// - currencyPosition: the currency position, either right, left, right_space, or left_space.
124+
/// - currencyCode: the three-letter country code used for a currency, e.g. CAD.
125+
126+
// -TODO: currency position should be an enum somewhere. Maybe in the Money struct?
127+
func formatCurrency(using localizedAmount: String, positionedAt currencyPosition: String, with currencyCode: Currency.Code) -> String? {
128+
return ""
129+
}
130+
120131

121132
// MARK: - Helper methods
122133

WooCommerce/WooCommerceTests/Tools/CurrencyTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class CurrencyTests: XCTestCase {
99
/// Test currency symbol lookup returns correctly encoded symbol.
1010
///
1111
func testCurrencySymbol() {
12-
let currency = Currency(amount: 0.00, code: .AED)
12+
let currency = Currency(amount: 0.00, code: .AED, position: .left)
1313
let symbol = currency.symbol
1414
XCTAssertEqual("د.إ", symbol)
1515
}

WooCommerce/WooCommerceTests/Tools/MoneyFormatterTests.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,19 +485,26 @@ extension MoneyFormatter {
485485
guard let decimal = decimalAmount else {
486486
DDLogError("Error: invalid string amount. Cannot convert to decimal.")
487487
XCTFail()
488+
return
488489
}
489490

490-
let localizedAmount = MoneyFormatter().localizeAmount(decimal: decimal,
491+
let amount = MoneyFormatter().localizeAmount(decimal: decimal,
491492
decimalSeparator: decimalSeparator,
492493
decimalPosition: decimalPosition,
493494
thousandSeparator: thousandSeparator)
494495

496+
guard let localizedAmount = amount else {
497+
XCTFail()
498+
return
499+
}
500+
495501
let formattedAmount = MoneyFormatter().formatCurrency(using: localizedAmount,
496502
positionedAt: currencyPosition,
497503
with: currencyCode)
498504

499505
guard let actualResult = formattedAmount else {
500506
XCTFail()
507+
return
501508
}
502509

503510
XCTAssertEqual(expectedResult, actualResult)

0 commit comments

Comments
 (0)