|
1 | 1 | package fr.free.nrw.commons.category
|
2 | 2 |
|
3 | 3 | import categoryItem
|
| 4 | +import com.nhaarman.mockitokotlin2.any |
4 | 5 | import com.nhaarman.mockitokotlin2.mock
|
| 6 | +import com.nhaarman.mockitokotlin2.times |
5 | 7 | import com.nhaarman.mockitokotlin2.verify
|
6 | 8 | import com.nhaarman.mockitokotlin2.whenever
|
7 | 9 | import depictedItem
|
@@ -90,14 +92,18 @@ class CategoriesModelTest {
|
90 | 92 | val depictedItem =
|
91 | 93 | depictedItem(
|
92 | 94 | commonsCategories =
|
93 |
| -listOf( |
94 |
| -CategoryItem( |
95 |
| -"depictionCategory", |
96 |
| -"", |
97 |
| -"", |
98 |
| -false, |
99 |
| -), |
| 95 | +listOf( |
| 96 | +CategoryItem( |
| 97 | +"depictionCategory", |
| 98 | +"", |
| 99 | +"", |
| 100 | +false, |
100 | 101 | ),
|
| 102 | +), |
| 103 | +) |
| 104 | +val depictedItemWithoutCategories = |
| 105 | +depictedItem( |
| 106 | +imageUrl = "testUrl" |
101 | 107 | )
|
102 | 108 |
|
103 | 109 | whenever(gpsCategoryModel.categoriesFromLocation)
|
@@ -159,6 +165,23 @@ class CategoriesModelTest {
|
159 | 165 | ),
|
160 | 166 | ),
|
161 | 167 | )
|
| 168 | +whenever( |
| 169 | +categoryClient.getCategoriesOfImage( |
| 170 | +"testUrl", |
| 171 | +25, |
| 172 | +), |
| 173 | +).thenReturn( |
| 174 | +Single.just( |
| 175 | +listOf( |
| 176 | +CategoryItem( |
| 177 | +"categoriesOfP18", |
| 178 | +"", |
| 179 | +"", |
| 180 | +false, |
| 181 | +), |
| 182 | +), |
| 183 | +), |
| 184 | +) |
162 | 185 | val imageTitleList = listOf("Test")
|
163 | 186 | CategoriesModel(categoryClient, categoryDao, gpsCategoryModel)
|
164 | 187 | .searchAll("", imageTitleList, listOf(depictedItem))
|
@@ -171,8 +194,21 @@ class CategoriesModelTest {
|
171 | 194 | categoryItem("recentCategories"),
|
172 | 195 | ),
|
173 | 196 | )
|
| 197 | +CategoriesModel(categoryClient, categoryDao, gpsCategoryModel) |
| 198 | +.searchAll("", imageTitleList, listOf(depictedItemWithoutCategories)) |
| 199 | +.test() |
| 200 | +.assertValue( |
| 201 | +listOf( |
| 202 | +categoryItem("categoriesOfP18"), |
| 203 | +categoryItem("gpsCategory"), |
| 204 | +categoryItem("titleSearch"), |
| 205 | +categoryItem("recentCategories"), |
| 206 | +), |
| 207 | +) |
174 | 208 | imageTitleList.forEach {
|
175 |
| -verify(categoryClient).searchCategories(it, CategoriesModel.SEARCH_CATS_LIMIT) |
| 209 | +verify(categoryClient, times(2)).searchCategories(it, CategoriesModel.SEARCH_CATS_LIMIT) |
| 210 | +verify(categoryClient).getCategoriesByName(any(), any(), any(), any()) |
| 211 | +verify(categoryClient).getCategoriesOfImage(any(), any()) |
176 | 212 | }
|
177 | 213 | }
|
178 | 214 |
|
|
0 commit comments