Skip to content

Commit

Permalink
tests for GetTravelAddonOfferUseCase
Browse files Browse the repository at this point in the history
  • Loading branch information
panasetskaya committed Dec 16, 2024
1 parent c2252ef commit 7b72580
Show file tree
Hide file tree
Showing 3 changed files with 354 additions and 86 deletions.
13 changes: 13 additions & 0 deletions app/feature/feature-addon-purchase/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,17 @@ dependencies {
implementation(projects.navigationComposeTyped)
implementation(projects.navigationCore)
implementation(projects.uiTiersAndAddons)

testImplementation(libs.apollo.testingSupport)
testImplementation(libs.assertK)
testImplementation(libs.coroutines.test)
testImplementation(libs.junit)
testImplementation(libs.turbine)
testImplementation(projects.apolloOctopusTest)
testImplementation(projects.apolloTest)
testImplementation(projects.coreCommonTest)
testImplementation(projects.featureFlagsTest)
testImplementation(projects.languageTest)
testImplementation(projects.loggingTest)
testImplementation(projects.moleculeTest)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@ package com.hedvig.android.feature.addon.purchase.data

import arrow.core.Either
import arrow.core.NonEmptyList
import arrow.core.nonEmptyListOf
import arrow.core.raise.either
import arrow.core.toNonEmptyListOrNull
import com.apollographql.apollo.ApolloClient
import com.hedvig.android.apollo.safeExecute
import com.hedvig.android.core.common.ErrorMessage
import com.hedvig.android.core.uidata.UiCurrencyCode
import com.hedvig.android.core.uidata.UiMoney
import com.hedvig.android.data.productvariant.InsuranceVariantDocument
import com.hedvig.android.feature.addon.purchase.data.Addon.TravelAddonOffer
import com.hedvig.android.featureflags.FeatureManager
import com.hedvig.android.featureflags.flags.Feature
import com.hedvig.android.logger.LogPriority
import com.hedvig.android.logger.logcat
import kotlin.String
import kotlinx.coroutines.flow.first
import kotlinx.datetime.LocalDate
import octopus.UpsellAddonOfferMutation

internal interface GetTravelAddonOfferUseCase {
Expand Down Expand Up @@ -99,85 +95,3 @@ private fun UpsellAddonOfferMutation.Data.UpsellTravelAddonOffer.Offer.CurrentAd
)
}
}

// todo: remove mocks when not needed
private val mockWithoutUpgrade = TravelAddonOffer(
addonOptions = nonEmptyListOf(
TravelAddonQuote(
quoteId = "id",
addonId = "addonId1",
displayName = "45 days",
addonVariant = AddonVariant(
termsVersion = "terms",
documents = listOf(
InsuranceVariantDocument(
"Terms and conditions",
"www.url.com",
InsuranceVariantDocument.InsuranceDocumentType.TERMS_AND_CONDITIONS,
),
),
displayDetails = listOf("Coverage" to "45 days", "Insured people" to "You+1"),
),
price = UiMoney(
49.0,
UiCurrencyCode.SEK,
),
),
TravelAddonQuote(
displayName = "60 days",
addonId = "addonId1",
quoteId = "id",
addonVariant = AddonVariant(
termsVersion = "terms",
documents = listOf(
InsuranceVariantDocument(
"Terms and conditions",
"www.url.com",
InsuranceVariantDocument.InsuranceDocumentType.TERMS_AND_CONDITIONS,
),
),
displayDetails = listOf("Coverage" to "60 days", "Insured people" to "You+1"),
),
price = UiMoney(
60.0,
UiCurrencyCode.SEK,
),
),
),
title = "Travel plus",
description = "For those who travel often: luggage protection and 24/7 assistance worldwide",
activationDate = LocalDate(2025, 1, 1),
currentTravelAddon = null,
)

private val mockWithUpgrade = TravelAddonOffer(
addonOptions = nonEmptyListOf(
TravelAddonQuote(
displayName = "60 days",
addonId = "addonId1",
quoteId = "id",
addonVariant = AddonVariant(
termsVersion = "terms",
documents = listOf(
InsuranceVariantDocument(
"Terms and conditions",
"www.url.com",
InsuranceVariantDocument.InsuranceDocumentType.TERMS_AND_CONDITIONS,
),
),
displayDetails = listOf("Coverage" to "60 days", "Insured people" to "You+1"),
),
price = UiMoney(
60.0,
UiCurrencyCode.SEK,
),
),
),
title = "Travel plus",
description = "For those who travel often: luggage protection and 24/7 assistance worldwide",
activationDate = LocalDate(2025, 1, 1),
currentTravelAddon = CurrentTravelAddon(
UiMoney(49.0, UiCurrencyCode.SEK),
listOf("Coverage" to "45 days", "Insured people" to "You+1"),
),
)
Loading

0 comments on commit 7b72580

Please sign in to comment.