mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Add bookmark location controller test (#3947)
This commit is contained in:
parent
257e8c57dd
commit
44fb1534bb
1 changed files with 50 additions and 0 deletions
|
|
@ -0,0 +1,50 @@
|
|||
package fr.free.nrw.commons.bookmarks.locations
|
||||
|
||||
import android.net.Uri
|
||||
import com.nhaarman.mockitokotlin2.whenever
|
||||
import fr.free.nrw.commons.bookmarks.Bookmark
|
||||
import fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesDao
|
||||
import fr.free.nrw.commons.nearby.Place
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.InjectMocks
|
||||
import org.mockito.Mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
import java.util.ArrayList
|
||||
|
||||
class BookmarkLocationControllerTest {
|
||||
@Mock
|
||||
var bookmarkDao: BookmarkLocationsDao? = null
|
||||
@InjectMocks
|
||||
lateinit var bookmarkLocationsController: BookmarkLocationsController
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
whenever(bookmarkDao!!.allBookmarksLocations)
|
||||
.thenReturn(mockBookmarkList)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mock bookmark list
|
||||
* @return
|
||||
*/
|
||||
private val mockBookmarkList: List<Place>
|
||||
private get() {
|
||||
val list = ArrayList<Place>()
|
||||
list.add(Place("a place",null,"a description",null,"a cat",null,null,null))
|
||||
list.add(Place("another place",null,"another description",null,"another cat",null,null,null))
|
||||
return list
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case where all bookmark locations are fetched and media is found against it
|
||||
*/
|
||||
@Test
|
||||
fun loadBookmarkedLocations() {
|
||||
val bookmarkedLocations =
|
||||
bookmarkLocationsController!!.loadFavoritesLocations()
|
||||
Assert.assertEquals(2, bookmarkedLocations.size.toLong())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue