Skip to content

Commit

Permalink
Update InsightsManagementMapperTest.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
ravishanker committed Feb 22, 2024
1 parent cb86656 commit 88734d0
Showing 1 changed file with 32 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.assertj.core.api.Assertions.assertThat
import org.junit.Before
import org.junit.Test
import org.mockito.Mock
import org.wordpress.android.BaseUnitTest
import org.wordpress.android.R
import org.wordpress.android.fluxc.store.StatsStore.InsightType
Expand All @@ -16,22 +17,26 @@ import org.wordpress.android.fluxc.store.StatsStore.InsightType.MOST_POPULAR_DAY
import org.wordpress.android.fluxc.store.StatsStore.InsightType.POSTING_ACTIVITY
import org.wordpress.android.fluxc.store.StatsStore.InsightType.PUBLICIZE
import org.wordpress.android.fluxc.store.StatsStore.InsightType.TAGS_AND_CATEGORIES
import org.wordpress.android.fluxc.store.StatsStore.InsightType.TODAY_STATS
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management.InsightsManagementViewModel.InsightListItem
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management.InsightsManagementViewModel.InsightListItem.Header
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management.InsightsManagementViewModel.InsightListItem.InsightModel
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management.InsightsManagementViewModel.InsightListItem.InsightModel.Status
import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig

@ExperimentalCoroutinesApi
class InsightsManagementMapperTest : BaseUnitTest() {
@Mock
private lateinit var trafficTabFeatureConfig: StatsTrafficTabFeatureConfig

private lateinit var insightsManagementMapper: InsightsManagementMapper
private val insightTypeCount = 10 // POSTS_AND_PAGES_INSIGHTS.size + ACTIVITY_INSIGHTS.size + GENERAL_INSIGHTS.size
private var insightTypeCount = 9 // POSTS_AND_PAGES_INSIGHTS.size + ACTIVITY_INSIGHTS.size + GENERAL_INSIGHTS.size
private val sectionsCount = 3

@Before
fun setUp() {
insightsManagementMapper = InsightsManagementMapper(
testDispatcher()
testDispatcher(),
trafficTabFeatureConfig
)
}

Expand All @@ -49,15 +54,14 @@ class InsightsManagementMapperTest : BaseUnitTest() {
assertInsight(result[1], ALL_TIME_STATS, true)
assertInsight(result[2], MOST_POPULAR_DAY_AND_HOUR, true)
assertInsight(result[3], ANNUAL_SITE_STATS, true)
assertInsight(result[4], TODAY_STATS, true)
assertHeader(result[5], R.string.stats_insights_management_posts_and_pages)
assertInsight(result[6], LATEST_POST_SUMMARY, true)
assertInsight(result[7], POSTING_ACTIVITY, true)
assertInsight(result[8], TAGS_AND_CATEGORIES, true)
assertHeader(result[9], R.string.stats_insights_management_activity)
assertInsight(result[10], FOLLOWERS, true)
assertInsight(result[11], FOLLOWER_TOTALS, true)
assertInsight(result[12], PUBLICIZE, true)
assertHeader(result[4], R.string.stats_insights_management_posts_and_pages)
assertInsight(result[5], LATEST_POST_SUMMARY, true)
assertInsight(result[6], POSTING_ACTIVITY, true)
assertInsight(result[7], TAGS_AND_CATEGORIES, true)
assertHeader(result[8], R.string.stats_insights_management_activity)
assertInsight(result[9], FOLLOWERS, true)
assertInsight(result[10], FOLLOWER_TOTALS, true)
assertInsight(result[11], PUBLICIZE, true)
}

@Test
Expand All @@ -74,15 +78,14 @@ class InsightsManagementMapperTest : BaseUnitTest() {
assertInsight(result[1], ALL_TIME_STATS, true)
assertInsight(result[2], MOST_POPULAR_DAY_AND_HOUR, false)
assertInsight(result[3], ANNUAL_SITE_STATS, false)
assertInsight(result[4], TODAY_STATS, false)
assertHeader(result[5], R.string.stats_insights_management_posts_and_pages)
assertInsight(result[6], LATEST_POST_SUMMARY, false)
assertInsight(result[7], POSTING_ACTIVITY, false)
assertInsight(result[8], TAGS_AND_CATEGORIES, false)
assertHeader(result[9], R.string.stats_insights_management_activity)
assertInsight(result[10], FOLLOWERS, false)
assertInsight(result[11], FOLLOWER_TOTALS, false)
assertInsight(result[12], PUBLICIZE, true)
assertHeader(result[4], R.string.stats_insights_management_posts_and_pages)
assertInsight(result[5], LATEST_POST_SUMMARY, false)
assertInsight(result[6], POSTING_ACTIVITY, false)
assertInsight(result[7], TAGS_AND_CATEGORIES, false)
assertHeader(result[8], R.string.stats_insights_management_activity)
assertInsight(result[9], FOLLOWERS, false)
assertInsight(result[10], FOLLOWER_TOTALS, false)
assertInsight(result[11], PUBLICIZE, true)
}

@Test
Expand All @@ -96,15 +99,14 @@ class InsightsManagementMapperTest : BaseUnitTest() {
assertInsight(result[1], ALL_TIME_STATS, false)
assertInsight(result[2], MOST_POPULAR_DAY_AND_HOUR, false)
assertInsight(result[3], ANNUAL_SITE_STATS, false)
assertInsight(result[4], TODAY_STATS, false)
assertHeader(result[5], R.string.stats_insights_management_posts_and_pages)
assertInsight(result[6], LATEST_POST_SUMMARY, false)
assertInsight(result[7], POSTING_ACTIVITY, false)
assertInsight(result[8], TAGS_AND_CATEGORIES, false)
assertHeader(result[9], R.string.stats_insights_management_activity)
assertInsight(result[10], FOLLOWERS, false)
assertInsight(result[11], FOLLOWER_TOTALS, false)
assertInsight(result[12], PUBLICIZE, false)
assertHeader(result[4], R.string.stats_insights_management_posts_and_pages)
assertInsight(result[5], LATEST_POST_SUMMARY, false)
assertInsight(result[6], POSTING_ACTIVITY, false)
assertInsight(result[7], TAGS_AND_CATEGORIES, false)
assertHeader(result[8], R.string.stats_insights_management_activity)
assertInsight(result[9], FOLLOWERS, false)
assertInsight(result[10], FOLLOWER_TOTALS, false)
assertInsight(result[11], PUBLICIZE, false)
}

private fun assertHeader(item: InsightListItem, text: Int) {
Expand Down

0 comments on commit 88734d0

Please sign in to comment.