@@ -42,13 +42,13 @@ import org.wordpress.android.util.SiteUtils.GB_EDITOR_NAME
42
42
import org.wordpress.android.viewmodel.mlp.ModalLayoutPickerViewModel.PageRequest.Blank
43
43
import org.wordpress.android.viewmodel.mlp.ModalLayoutPickerViewModel.PageRequest.Create
44
44
45
- @RunWith(MockitoJUnitRunner ::class )
46
45
@InternalCoroutinesApi
46
+ @ExperimentalCoroutinesApi
47
+ @RunWith(MockitoJUnitRunner ::class )
47
48
class ModalLayoutPickerViewModelTest {
48
49
@Rule
49
50
@JvmField val rule = InstantTaskExecutorRule ()
50
51
51
- @ExperimentalCoroutinesApi
52
52
@Rule
53
53
@JvmField val coroutineScope = MainCoroutineScopeRule ()
54
54
@@ -104,7 +104,6 @@ class ModalLayoutPickerViewModelTest {
104
104
)
105
105
}
106
106
107
- @ExperimentalCoroutinesApi
108
107
private fun <T > mockFetchingSelectedSite (
109
108
isError : Boolean = false,
110
109
isSiteUnavailable : Boolean = false,
@@ -144,67 +143,58 @@ class ModalLayoutPickerViewModelTest {
144
143
}
145
144
}
146
145
147
- @ExperimentalCoroutinesApi
148
146
@Test
149
147
fun `when the user scroll beyond a threshold the title becomes visible` () = mockFetchingSelectedSite {
150
148
viewModel.createPageFlowTriggered()
151
149
viewModel.onAppBarOffsetChanged(9 , 10 )
152
150
assertThat(requireNotNull(viewModel.uiState.value as Content ).isHeaderVisible).isEqualTo(true )
153
151
}
154
152
155
- @ExperimentalCoroutinesApi
156
153
@Test
157
154
fun `when the user scroll bellow a threshold the title remains hidden` () = mockFetchingSelectedSite {
158
155
viewModel.createPageFlowTriggered()
159
156
viewModel.onAppBarOffsetChanged(11 , 10 )
160
157
assertThat(requireNotNull(viewModel.uiState.value as Content ).isHeaderVisible).isEqualTo(false )
161
158
}
162
159
163
- @ExperimentalCoroutinesApi
164
160
@Test
165
161
fun `when modal layout picker starts the categories are loaded` () = mockFetchingSelectedSite {
166
162
viewModel.createPageFlowTriggered()
167
163
assertThat(requireNotNull(viewModel.uiState.value as Content ).categories.size).isGreaterThan(0 )
168
164
}
169
165
170
- @ExperimentalCoroutinesApi
171
166
@Test
172
167
fun `when modal layout picker starts the layouts are loaded` () = mockFetchingSelectedSite {
173
168
viewModel.createPageFlowTriggered()
174
169
assertThat(requireNotNull(viewModel.uiState.value as Content ).layoutCategories.size).isGreaterThan(0 )
175
170
}
176
171
177
- @ExperimentalCoroutinesApi
178
172
@Test
179
173
fun `when modal layout picker starts fetch errors are handled` () = mockFetchingSelectedSite(true ) {
180
174
viewModel.createPageFlowTriggered()
181
175
assertThat(viewModel.uiState.value is Error ).isEqualTo(true )
182
176
}
183
177
184
- @ExperimentalCoroutinesApi
185
178
@Test
186
179
fun `when modal layout picker starts and the site is unavailable errors are handled` () =
187
180
mockFetchingSelectedSite(isSiteUnavailable = true ) {
188
181
viewModel.createPageFlowTriggered()
189
182
assertThat(viewModel.uiState.value is Error ).isEqualTo(true )
190
183
}
191
184
192
- @ExperimentalCoroutinesApi
193
185
@Test
194
186
fun `modal layout picker is shown when triggered` () = mockFetchingSelectedSite {
195
187
viewModel.createPageFlowTriggered()
196
188
assertThat(viewModel.isModalLayoutPickerShowing.value!! .peekContent()).isEqualTo(true )
197
189
}
198
190
199
- @ExperimentalCoroutinesApi
200
191
@Test
201
192
fun `modal layout picker is dismissed when the user hits the back button` () = mockFetchingSelectedSite {
202
193
viewModel.createPageFlowTriggered()
203
194
viewModel.dismiss()
204
195
assertThat(viewModel.isModalLayoutPickerShowing.value!! .peekContent()).isEqualTo(false )
205
196
}
206
197
207
- @ExperimentalCoroutinesApi
208
198
@Test
209
199
fun `when no layout is selected and the create page is triggered the blank page creation flow starts` () =
210
200
mockFetchingSelectedSite {
@@ -215,7 +205,6 @@ class ModalLayoutPickerViewModelTest {
215
205
assertThat(captor.value).isEqualTo(Blank )
216
206
}
217
207
218
- @ExperimentalCoroutinesApi
219
208
@Test
220
209
fun `when a layout is selected and the create page is triggered the page creation flow starts with a template` () =
221
210
mockFetchingSelectedSite {
@@ -228,14 +217,12 @@ class ModalLayoutPickerViewModelTest {
228
217
assertThat(captor.value.template).isEqualTo(" about" )
229
218
}
230
219
231
- @ExperimentalCoroutinesApi
232
220
@Test
233
221
fun `when modal layout picker starts no layout is selected` () = mockFetchingSelectedSite {
234
222
viewModel.createPageFlowTriggered()
235
223
assertThat(requireNotNull(viewModel.uiState.value as Content ).selectedLayoutSlug).isNull()
236
224
}
237
225
238
- @ExperimentalCoroutinesApi
239
226
@Test
240
227
fun `when the user taps on a layout the layout is selected if the thumbnail has loaded` () =
241
228
mockFetchingSelectedSite {
@@ -246,7 +233,6 @@ class ModalLayoutPickerViewModelTest {
246
233
.isEqualTo(" about-1" )
247
234
}
248
235
249
- @ExperimentalCoroutinesApi
250
236
@Test
251
237
fun `when the user taps on a layout the layout is selected if the thumbnail has not loaded` () =
252
238
mockFetchingSelectedSite {
@@ -256,7 +242,6 @@ class ModalLayoutPickerViewModelTest {
256
242
.isNotEqualTo(" about-1" )
257
243
}
258
244
259
- @ExperimentalCoroutinesApi
260
245
@Test
261
246
fun `when the user taps on a selected layout the layout is deselected` () = mockFetchingSelectedSite {
262
247
viewModel.createPageFlowTriggered()
@@ -265,7 +250,6 @@ class ModalLayoutPickerViewModelTest {
265
250
assertThat(requireNotNull(viewModel.uiState.value as Content ).selectedLayoutSlug).isNull()
266
251
}
267
252
268
- @ExperimentalCoroutinesApi
269
253
@Test
270
254
fun `when the modal layout picker is dismissed the layout is deselected` () = mockFetchingSelectedSite {
271
255
viewModel.createPageFlowTriggered()
@@ -274,14 +258,12 @@ class ModalLayoutPickerViewModelTest {
274
258
assertThat(requireNotNull(viewModel.uiState.value as Content ).selectedLayoutSlug).isNull()
275
259
}
276
260
277
- @ExperimentalCoroutinesApi
278
261
@Test
279
262
fun `when modal layout picker starts no category is selected` () = mockFetchingSelectedSite {
280
263
viewModel.createPageFlowTriggered()
281
264
assertThat(requireNotNull(viewModel.uiState.value as Content ).selectedCategoriesSlugs).isEmpty()
282
265
}
283
266
284
- @ExperimentalCoroutinesApi
285
267
@Test
286
268
fun `when the user taps on a category the category is selected` () = mockFetchingSelectedSite {
287
269
viewModel.createPageFlowTriggered()
@@ -290,7 +272,6 @@ class ModalLayoutPickerViewModelTest {
290
272
.contains(" about" )
291
273
}
292
274
293
- @ExperimentalCoroutinesApi
294
275
@Test
295
276
fun `when the user taps on a selected category the category is deselected` () = mockFetchingSelectedSite {
296
277
viewModel.createPageFlowTriggered()
@@ -300,7 +281,6 @@ class ModalLayoutPickerViewModelTest {
300
281
.doesNotContain(" about" )
301
282
}
302
283
303
- @ExperimentalCoroutinesApi
304
284
@Test
305
285
fun `when the modal layout picker is dismissed the category is deselected` () = mockFetchingSelectedSite {
306
286
viewModel.createPageFlowTriggered()
@@ -309,15 +289,13 @@ class ModalLayoutPickerViewModelTest {
309
289
assertThat(requireNotNull(viewModel.uiState.value as Content ).selectedCategoriesSlugs).isEmpty()
310
290
}
311
291
312
- @ExperimentalCoroutinesApi
313
292
@Test
314
293
fun `when no layout is selected the create blank page button is visible` () = mockFetchingSelectedSite {
315
294
viewModel.createPageFlowTriggered()
316
295
assertThat(requireNotNull(viewModel.uiState.value as Content ).buttonsUiState.createBlankPageVisible)
317
296
.isEqualTo(true )
318
297
}
319
298
320
- @ExperimentalCoroutinesApi
321
299
@Test
322
300
fun `when a layout is selected the create blank page button is not visible` () = mockFetchingSelectedSite {
323
301
viewModel.createPageFlowTriggered()
@@ -327,15 +305,13 @@ class ModalLayoutPickerViewModelTest {
327
305
.isEqualTo(false )
328
306
}
329
307
330
- @ExperimentalCoroutinesApi
331
308
@Test
332
309
fun `when no layout is selected the create page button is not visible` () = mockFetchingSelectedSite {
333
310
viewModel.createPageFlowTriggered()
334
311
assertThat(requireNotNull(viewModel.uiState.value as Content ).buttonsUiState.createPageVisible)
335
312
.isEqualTo(false )
336
313
}
337
314
338
- @ExperimentalCoroutinesApi
339
315
@Test
340
316
fun `when a layout is selected the create page button is visible` () = mockFetchingSelectedSite {
341
317
viewModel.createPageFlowTriggered()
@@ -345,15 +321,13 @@ class ModalLayoutPickerViewModelTest {
345
321
.isEqualTo(true )
346
322
}
347
323
348
- @ExperimentalCoroutinesApi
349
324
@Test
350
325
fun `when no layout is selected the preview button is not visible` () = mockFetchingSelectedSite {
351
326
viewModel.createPageFlowTriggered()
352
327
assertThat(requireNotNull(viewModel.uiState.value as Content ).buttonsUiState.previewVisible)
353
328
.isEqualTo(false )
354
329
}
355
330
356
- @ExperimentalCoroutinesApi
357
331
@Test
358
332
fun `when a layout is selected the preview button is visible` () = mockFetchingSelectedSite {
359
333
viewModel.createPageFlowTriggered()
0 commit comments