@@ -108,6 +108,10 @@ class RewardViewUtilsTest : KSRobolectricTestCase() {
108108 .estimatedMin(2.0 )
109109 .estimatedMax(20.0 )
110110 .build()
111+ val caRule = ShippingRuleFactory .canadaShippingRule().toBuilder()
112+ .estimatedMin(3.0 )
113+ .estimatedMax(30.0 )
114+ .build()
111115
112116 val shippingPreference = Reward .ShippingPreference .UNRESTRICTED
113117 val reward = RewardFactory .reward().toBuilder()
@@ -118,7 +122,7 @@ class RewardViewUtilsTest : KSRobolectricTestCase() {
118122 .build()
119123 val rewards = listOf (reward)
120124
121- val selectedShippingRule = usRule
125+ val selectedShippingRule = caRule
122126
123127 val estimatedShippingString = RewardViewUtils .getEstimatedShippingCostString(
124128 context, ksCurrency, ksString, project, rewards, selectedShippingRule,
@@ -131,7 +135,7 @@ class RewardViewUtilsTest : KSRobolectricTestCase() {
131135 }
132136
133137 @Test
134- fun `test estimated shipping range for reward with worldwide shipping uses first selected shipping rule when forced ` () {
138+ fun `test estimated shipping range for reward with restricted shipping` () {
135139 val context = context()
136140
137141 val config = ConfigFactory .configForUSUser()
@@ -140,7 +144,7 @@ class RewardViewUtilsTest : KSRobolectricTestCase() {
140144 val ksCurrency = KSCurrency (currentConfig)
141145
142146 val ksString = ksString()
143- val project = ProjectFactory .project() // KSCurrency.formatWithUserPreference()
147+ val project = ProjectFactory .project()
144148
145149 val usRule = ShippingRuleFactory .usShippingRule().toBuilder()
146150 .estimatedMin(1.0 )
@@ -151,11 +155,12 @@ class RewardViewUtilsTest : KSRobolectricTestCase() {
151155 .estimatedMax(20.0 )
152156 .build()
153157
154- val shippingPreference = Reward .ShippingPreference .UNRESTRICTED
158+ val shippingPreference = Reward .ShippingPreference .RESTRICTED
159+
155160 val reward = RewardFactory .reward().toBuilder()
156- .shippingPreference(shippingPreference.name)
157- .shippingType(shippingPreference.name)
158161 .shippingPreferenceType(shippingPreference)
162+ .shippingPreference(shippingPreference.name.lowercase())
163+ .shippingType(shippingPreference.name.lowercase())
159164 .shippingRules(listOf (mxRule, usRule))
160165 .build()
161166 val rewards = listOf (reward)
@@ -167,9 +172,42 @@ class RewardViewUtilsTest : KSRobolectricTestCase() {
167172 multipleQuantitiesAllowed = false ,
168173 useUserPreference = false ,
169174 useAbout = false ,
170- forceSelectedShippingRule = true
171175 )
172176
173177 assertEquals(" $1-$10" , estimatedShippingString)
174178 }
179+
180+ @Test
181+ fun `test estimated shipping range for digital reward` () {
182+ val context = context()
183+
184+ val config = ConfigFactory .configForUSUser()
185+ val currentConfig = MockCurrentConfigV2 ()
186+ currentConfig.config(config)
187+ val ksCurrency = KSCurrency (currentConfig)
188+
189+ val ksString = ksString()
190+ val project = ProjectFactory .project()
191+
192+ val shippingPreference = Reward .ShippingPreference .NONE
193+
194+ val reward = RewardFactory .reward().toBuilder()
195+ .shippingPreferenceType(shippingPreference)
196+ .shippingPreference(shippingPreference.name.lowercase())
197+ .shippingType(shippingPreference.name.lowercase())
198+ .shippingRules(listOf ())
199+ .build()
200+ val rewards = listOf (reward)
201+
202+ val selectedShippingRule = ShippingRuleFactory .usShippingRule()
203+
204+ val estimatedShippingString = RewardViewUtils .getEstimatedShippingCostString(
205+ context, ksCurrency, ksString, project, rewards, selectedShippingRule,
206+ multipleQuantitiesAllowed = false ,
207+ useUserPreference = false ,
208+ useAbout = false ,
209+ )
210+
211+ assertTrue(estimatedShippingString.isEmpty())
212+ }
175213}
0 commit comments