From 49662f5a64fee88e4e703fc671c92f88a60d5c13 Mon Sep 17 00:00:00 2001 From: Justin Swart Date: Tue, 30 Jun 2020 08:26:51 -0700 Subject: [PATCH] [NT-1405] Use bonus support as total for No Reward (#1240) * Use bonus amount as total for no reward * Fix snapshot test --- .../ManagePledgeViewControllerTests.swift | 5 +--- .../PledgeAmountSummaryViewModel.swift | 2 +- .../PledgeAmountSummaryViewModelTests.swift | 24 ++++++++++++++++--- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Kickstarter-iOS/Views/Controllers/ManagePledgeViewControllerTests.swift b/Kickstarter-iOS/Views/Controllers/ManagePledgeViewControllerTests.swift index cc22a368f6..ce0e33f7b6 100644 --- a/Kickstarter-iOS/Views/Controllers/ManagePledgeViewControllerTests.swift +++ b/Kickstarter-iOS/Views/Controllers/ManagePledgeViewControllerTests.swift @@ -176,14 +176,11 @@ final class ManagePledgeViewControllerTests: TestCase { |> \.backing.shippingAmount .~ nil envelope = envelope + |> \.backing.bonusAmount .~ Money(amount: 10.0, currency: .gbp, symbol: "£") |> \.backing.pledgedOn .~ TimeInterval(1_475_361_315) |> \.backing.amount .~ Money(amount: 10.0, currency: .gbp, symbol: "£") |> \.backing.backer.uid .~ user.id |> \.backing.backer.name .~ "Blob" - |> \.backing.reward .~ ( - ManagePledgeViewBackingEnvelope.Backing.Reward.template - |> \.amount .~ Money(amount: 10.0, currency: .gbp, symbol: "£") - ) let mockService = MockService( fetchManagePledgeViewBackingResult: .success(envelope), diff --git a/Library/ViewModels/PledgeAmountSummaryViewModel.swift b/Library/ViewModels/PledgeAmountSummaryViewModel.swift index 12b12bc66f..d4b79b9752 100644 --- a/Library/ViewModels/PledgeAmountSummaryViewModel.swift +++ b/Library/ViewModels/PledgeAmountSummaryViewModel.swift @@ -46,7 +46,7 @@ public class PledgeAmountSummaryViewModel: PledgeAmountSummaryViewModelType, .map { ( $0.projectCountry, - $0.rewardMinimum, + $0.isNoReward ? ($0.bonusAmount ?? 0) : $0.rewardMinimum, $0.omitUSCurrencyCode ) } diff --git a/Library/ViewModels/PledgeAmountSummaryViewModelTests.swift b/Library/ViewModels/PledgeAmountSummaryViewModelTests.swift index 28f3e6730d..773c743e16 100644 --- a/Library/ViewModels/PledgeAmountSummaryViewModelTests.swift +++ b/Library/ViewModels/PledgeAmountSummaryViewModelTests.swift @@ -111,14 +111,14 @@ final class PledgeAmountSummaryViewModelTests: TestCase { func testBonusAmountStackViewIsHidden_isTrue_WhenIsNoReward() { let data = PledgeAmountSummaryViewData( - bonusAmount: 0, + bonusAmount: 1, isNoReward: true, locationName: nil, omitUSCurrencyCode: true, projectCountry: Project.Country.us, pledgedOn: 1_568_666_243.0, - rewardMinimum: 30, - shippingAmount: 7.0 + rewardMinimum: 0, + shippingAmount: 0 ) self.vm.inputs.configureWith(data) @@ -144,4 +144,22 @@ final class PledgeAmountSummaryViewModelTests: TestCase { self.shippingLocationStackViewIsHidden.assertValue(true) } + + func testPledgeAmountText_NoReward() { + let data = PledgeAmountSummaryViewData( + bonusAmount: 2, + isNoReward: true, + locationName: nil, + omitUSCurrencyCode: true, + projectCountry: Project.Country.us, + pledgedOn: 1_568_666_243.0, + rewardMinimum: 0, + shippingAmount: 0 + ) + + self.vm.inputs.configureWith(data) + self.vm.inputs.viewDidLoad() + + self.pledgeAmountText.assertValues(["$2.00"], "Bonus amount is used as pledge total for No Reward type") + } }