Skip to content

Commit 11da227

Browse files
committed
fix coroutine tests
1 parent 5f10fcb commit 11da227

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

libnavigation-core/src/test/java/com/mapbox/navigation/core/trip/MapboxTripStarterTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class MapboxTripStarterTest {
7474
sut.onAttached(mapboxNavigation)
7575
every { PermissionsManager.areLocationPermissionsGranted(any()) } returns true
7676
sut.setLocationPermissionGranted(true)
77+
testCoroutineScope.cleanupTestCoroutines()
7778

7879
verify(exactly = 1) { mapboxNavigation.startTripSession() }
7980
}
@@ -84,13 +85,10 @@ class MapboxTripStarterTest {
8485

8586
val mapboxNavigation = mockMapboxNavigation()
8687
sut.onAttached(mapboxNavigation)
87-
sut.setLocationPermissionGranted(true)
8888

89-
// Clean up coroutines early so that the error is caught by the tests.
9089
assertThrows(Exception::class.java) {
91-
coroutineRule.createdScopes.forEach { it.cleanupTestCoroutines() }
90+
sut.setLocationPermissionGranted(true)
9291
}
93-
coroutineRule.createdScopes.clear()
9492
}
9593

9694
@Test
@@ -110,9 +108,10 @@ class MapboxTripStarterTest {
110108

111109
val mapboxNavigation = mockMapboxNavigation()
112110
sut.onAttached(mapboxNavigation)
113-
sut.update { it.tripType(MapboxTripStarterExtra.MAPBOX_TRIP_STARTER_REPLAY_ROUTE) }
114111
every { PermissionsManager.areLocationPermissionsGranted(any()) } returns true
115112
sut.setLocationPermissionGranted(true)
113+
sut.update { it.tripType(MapboxTripStarterExtra.MAPBOX_TRIP_STARTER_REPLAY_ROUTE) }
114+
testCoroutineScope.cleanupTestCoroutines()
116115

117116
verify(exactly = 1) { mapboxNavigation.startReplayTripSession() }
118117
}
@@ -125,6 +124,7 @@ class MapboxTripStarterTest {
125124

126125
sut.onAttached(mapboxNavigation)
127126
sut.update { it.tripType(MapboxTripStarterExtra.MAPBOX_TRIP_STARTER_REPLAY_ROUTE) }
127+
testCoroutineScope.cleanupTestCoroutines()
128128

129129
verify(exactly = 0) { mapboxNavigation.stopTripSession() }
130130
verify(exactly = 1) { mapboxNavigation.startReplayTripSession() }

0 commit comments

Comments
 (0)