Skip to content

Commit

Permalink
chore: fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-fiedler committed Mar 22, 2024
1 parent 3bf0585 commit d4299cd
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -377,19 +377,25 @@ class AmplitudeSessionTest {

@Test
fun amplitude_distantForegroundBackgroundEventsShouldStartNewSession() = runTest {
val amplitude = Amplitude(createConfiguration())
setDispatcher(amplitude, testScheduler)

// set up config
val config = createConfiguration()
val mockedPlugin = spyk(StubPlugin())
amplitude.add(mockedPlugin)
config.plugins = listOf(mockedPlugin)

// create instance (starts session) (1)
val amplitude = Amplitude(config)
setDispatcher(amplitude, testScheduler)
amplitude.isBuilt.await()

// Enter FG (2)
amplitude.onEnterForeground(StartTime)
val event1Time = mockSystemTime(StartTime + 500)
// Track (3)
amplitude.track(createEvent(event1Time, "test event 1"))
// Exit FG (4)
val exitForegroundTime = mockSystemTime(StartTime + 1000)
amplitude.onExitForeground(exitForegroundTime)
// Track (5)
val event2Time = mockSystemTime(exitForegroundTime + 1000)
amplitude.track(createEvent(event2Time, "test event 2"))

Expand Down

0 comments on commit d4299cd

Please sign in to comment.