mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 04:39:04 +00:00
update unit tests & monthsUntilNextHourglass
This commit is contained in:
parent
15f3b05337
commit
2d22c37652
2 changed files with 5 additions and 6 deletions
|
|
@ -11,9 +11,11 @@ open class SubscriptionPlan : RealmObject(), BaseObject {
|
|||
var customerId: String? = null
|
||||
var dateCreated: Date? = null
|
||||
var dateUpdated: Date? = null
|
||||
|
||||
@JvmField
|
||||
var dateTerminated: Date? = null
|
||||
var paymentMethod: String? = null
|
||||
|
||||
@JvmField
|
||||
var planId: String? = null
|
||||
var gemsBought: Int? = null
|
||||
|
|
@ -51,14 +53,11 @@ open class SubscriptionPlan : RealmObject(), BaseObject {
|
|||
If user has a initial basic monthly subscription, receive hourglasses on fourth month,
|
||||
else receive on third month (subtract 1 from total consecutive count)
|
||||
*/
|
||||
|
||||
val monthsUntilNextHourglass: Int?
|
||||
get() {
|
||||
return if (consecutive?.offset == 0) {
|
||||
if (consecutive?.count == 0) {
|
||||
4
|
||||
} else {
|
||||
(3 - (((consecutive?.count ?: 0) - 1) % 3))
|
||||
}
|
||||
(3 - (((consecutive?.count ?: 0)) % 3))
|
||||
} else {
|
||||
consecutive?.offset
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class SubscriptionPlanTest : WordSpec({
|
|||
|
||||
"months until next hourglass with initial basic sub" {
|
||||
plan.planId = SubscriptionPlan.PLANID_BASIC
|
||||
plan.monthsUntilNextHourglass shouldBe 4
|
||||
plan.monthsUntilNextHourglass shouldBe 3
|
||||
}
|
||||
|
||||
"months until receiving first hourglass with basic sub" {
|
||||
|
|
|
|||
Loading…
Reference in a new issue