update unit tests & monthsUntilNextHourglass

This commit is contained in:
Hafiz 2022-05-26 13:34:41 -04:00
parent 15f3b05337
commit 2d22c37652
2 changed files with 5 additions and 6 deletions

View file

@ -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
}

View file

@ -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" {