Skip to content

Commit

Permalink
Add FakeGtfsService
Browse files Browse the repository at this point in the history
  • Loading branch information
ksharma-xyz committed Jan 26, 2025
1 parent 84fba81 commit 0b781b8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ kotlin {
implementation(projects.feature.tripPlanner.ui)
implementation(projects.feature.tripPlanner.state)
implementation(projects.feature.tripPlanner.network)
implementation(projects.gtfsStatic)
implementation(projects.taj)

implementation(libs.test.kotlin)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package xyz.ksharma.core.test.fakes

import xyz.ksharma.krail.gtfs_static.NswGtfsService

class FakeGtfsService : NswGtfsService {

override suspend fun getSydneyTrains() {
// Do nothing
}

override suspend fun getSydneyMetro() {
// Do nothing
}

override suspend fun getLightRail() {
// Do nothing
}

override suspend fun getNswTrains() {
// Do nothing
}

override suspend fun getSydneyFerries() {
// Do nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.test.setMain
import xyz.ksharma.core.test.fakes.FakeAnalytics
import xyz.ksharma.core.test.fakes.FakeGtfsService
import xyz.ksharma.core.test.fakes.FakeSandook
import xyz.ksharma.core.test.helpers.AnalyticsTestHelper.assertScreenViewEventTracked
import xyz.ksharma.krail.core.analytics.Analytics
import xyz.ksharma.krail.core.analytics.AnalyticsScreen
import xyz.ksharma.krail.core.analytics.event.AnalyticsEvent
import xyz.ksharma.krail.gtfs_static.NswGtfsService
import xyz.ksharma.krail.sandook.Sandook
import xyz.ksharma.krail.trip.planner.ui.savedtrips.SavedTripsViewModel
import xyz.ksharma.krail.trip.planner.ui.state.savedtrip.SavedTripUiEvent
Expand All @@ -31,14 +33,15 @@ class SavedTripsViewModelTest {

private val sandook: Sandook = FakeSandook()
private val fakeAnalytics: Analytics = FakeAnalytics()
private val gtfsService: NswGtfsService = FakeGtfsService()
private lateinit var viewModel: SavedTripsViewModel

private val testDispatcher = StandardTestDispatcher()

@BeforeTest
fun setUp() {
Dispatchers.setMain(testDispatcher)
viewModel = SavedTripsViewModel(sandook, fakeAnalytics, testDispatcher)
viewModel = SavedTripsViewModel(sandook, fakeAnalytics, testDispatcher, gtfsService)
}

@AfterTest
Expand Down

0 comments on commit 0b781b8

Please sign in to comment.