Skip to content

Instantly share code, notes, and snippets.

@shredderskelton
Created February 20, 2021 13:57
Show Gist options
  • Select an option

  • Save shredderskelton/01451f20bb99b7ff306a3c0cd8849d35 to your computer and use it in GitHub Desktop.

Select an option

Save shredderskelton/01451f20bb99b7ff306a3c0cd8849d35 to your computer and use it in GitHub Desktop.
PeopleTest
class PeopleViewModelTest {
private lateinit var underTest: PeopleViewModel
private val service = mock<StarWarsService> {
onBlocking { getPeople() }
.then {
flow {
// Simulate multiple requests to backend
emit(Result.Success(listOf(dummyPerson)))
emit(Result.Success(listOf(dummyPerson2)))
}
}
}
@Before
fun setup() {
underTest = PeopleViewModel(service)
}
@Test
fun `People items translated and updated correctly`() {
runBlocking {
underTest.people.test {
assertEquals(listOf(lukeItem), expectItem())
assertEquals(listOf(lukeItem, nickItem), expectItem())
expectComplete()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment