Skip to content

Instantly share code, notes, and snippets.

@phellipealexandre
Last active July 11, 2021 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phellipealexandre/c4e73ffdd418fd2271be1be89daf0b21 to your computer and use it in GitHub Desktop.
Save phellipealexandre/c4e73ffdd418fd2271be1be89daf0b21 to your computer and use it in GitHub Desktop.
@Test
fun `Track analytics event when creating new note`() {
val analyticsWrapperSpy = //Spy
val noteAnalytics = NoteAnalytics(analyticsWrapperSpy) //System under test
//AnalyticsWrapperSpy records the interaction with NoteAnalytics under the hoods
noteAnalytics.trackCreateNewNoteEvent(NoteType.Supermarket)
//Based on the its internal implementation, the spy returns the state of the dependency
val numberOfEvents = analyticsWrapperSpy.getNewNoteEventsRegistered()
assertEquals(expected = 1, actual = numberOfEvents)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment