mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Fixed: Failing unit test case.
* Added a new unit test to verify that books located in the trash folder do not appear on the library screen.
This commit is contained in:
parent
6c1b82da3d
commit
8ded3d350a
@ -81,7 +81,17 @@ internal class NewBookDaoTest {
|
||||
verify { box.remove(listOf(deletedEntity)) }
|
||||
}
|
||||
|
||||
private fun expectEmissionOfExistingAndNotExistingBook():
|
||||
@Test
|
||||
fun `books removes entities whose files are in the trash folder`() {
|
||||
runBlocking {
|
||||
val (_, _) = expectEmissionOfExistingAndNotExistingBook(true)
|
||||
val books = newBookDao.books().test()
|
||||
delay(1000)
|
||||
books.assertValues(emptyList())
|
||||
}
|
||||
}
|
||||
|
||||
private fun expectEmissionOfExistingAndNotExistingBook(isInTrashFolder: Boolean = false):
|
||||
Pair<BookOnDiskEntity, BookOnDiskEntity> {
|
||||
val query: Query<BookOnDiskEntity> = mockk()
|
||||
every { box.query().build() } returns query
|
||||
@ -89,6 +99,10 @@ internal class NewBookDaoTest {
|
||||
val zimReaderSourceThatDoesNotExist = mockk<ZimReaderSource>()
|
||||
coEvery { zimReaderSourceThatExists.exists() } returns true
|
||||
coEvery { zimReaderSourceThatDoesNotExist.exists() } returns false
|
||||
every {
|
||||
zimReaderSourceThatExists.toDatabase()
|
||||
} returns if (isInTrashFolder) "/.Trash/test.zim" else ""
|
||||
every { zimReaderSourceThatDoesNotExist.toDatabase() } returns ""
|
||||
val entityThatExists = bookOnDiskEntity(zimReaderSource = zimReaderSourceThatExists)
|
||||
val entityThatDoesNotExist =
|
||||
bookOnDiskEntity(zimReaderSource = zimReaderSourceThatDoesNotExist)
|
||||
|
Loading…
x
Reference in New Issue
Block a user