Created
February 20, 2021 13:57
-
-
Save shredderskelton/01451f20bb99b7ff306a3c0cd8849d35 to your computer and use it in GitHub Desktop.
PeopleTest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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