Created
March 27, 2019 00:15
-
-
Save lisamariewatkins/869d617fdf78bfb240d35b00cf11d999 to your computer and use it in GitHub Desktop.
This file contains 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
@Test | |
@ExperimentalCoroutinesApi | |
fun `verify method returns result, caches images, and updates offset`() = runBlocking { | |
// Arrange | |
val deferred = CompletableDeferred(MockJsonResponse().with(1)) | |
every { | |
mockPetManager.getPetListAsync("78701", null) | |
} returns deferred | |
// Exercise | |
val result = petRepository.getNextPet() | |
// Assert | |
result.observeForever { | |
Assert.assertNotNull(it) | |
} | |
coVerify { | |
mockImageCache.cacheImages(any()) | |
} | |
Assert.assertEquals(deferred.getCompleted().petFinder.lastOffset.value, petRepository.offset) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment