Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Nested
@DisplayName("given I flag someone")
inner class FlagSomeone {
lateinit var testObserver: TestObserver<MatchEvent>
lateinit var targetProfile: Profile
@BeforeEach
fun setup() {
testObserver = matchViewModel.events.test()
repeat(INSTRUCTION_CARDS_NUM) { matchViewModel.swipe(MatchRating.Interested) }
val matchState = matchViewModel.matchState.value as MatchState.Started
val matchItem = matchState.stack.items.lastElement() as MatchItem.ProfileCard
targetProfile = matchItem.profile
matchViewModel.flagButtonTapped()
}
@Test
fun `then sends flagged event`() {
testObserver.values().last() shouldBeInstanceOf MatchEvent.FlagProfile::class
(testObserver.values().last() as MatchEvent.FlagProfile).apply {
profile.shouldBeEqualTo(targetProfile)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment