Skip to content

Commit

Permalink
[NT-1405] Use bonus support as total for No Reward (#1240)
Browse files Browse the repository at this point in the history
* Use bonus amount as total for no reward

* Fix snapshot test
  • Loading branch information
justinswart authored Jun 30, 2020
1 parent e711088 commit 49662f5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion Library/ViewModels/PledgeAmountSummaryViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class PledgeAmountSummaryViewModel: PledgeAmountSummaryViewModelType,
.map {
(
$0.projectCountry,
$0.rewardMinimum,
$0.isNoReward ? ($0.bonusAmount ?? 0) : $0.rewardMinimum,
$0.omitUSCurrencyCode
)
}
Expand Down
24 changes: 21 additions & 3 deletions Library/ViewModels/PledgeAmountSummaryViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
}
}

0 comments on commit 49662f5

Please sign in to comment.