feat(content): 전체 탭 외부 선택을 추가한다
This commit is contained in:
@@ -63,6 +63,13 @@ class ContentAllTabViewModel(
|
|||||||
loadFirstPage(selectedType, sort, selectedDayOfWeekFor(selectedType))
|
loadFirstPage(selectedType, sort, selectedDayOfWeekFor(selectedType))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun selectTypeAndSort(type: MainContentAllType, sort: ContentSort) {
|
||||||
|
selectedType = type
|
||||||
|
selectedSort = sort
|
||||||
|
selectedDayOfWeek = selectedDayOfWeekFor(type)
|
||||||
|
loadFirstPage(type, sort, selectedDayOfWeek)
|
||||||
|
}
|
||||||
|
|
||||||
fun changeDayOfWeek(dayOfWeek: SeriesPublishedDaysOfWeek) {
|
fun changeDayOfWeek(dayOfWeek: SeriesPublishedDaysOfWeek) {
|
||||||
if (!selectedType.usesDayOfWeekQuery()) return
|
if (!selectedType.usesDayOfWeekQuery()) return
|
||||||
|
|
||||||
|
|||||||
@@ -227,6 +227,70 @@ class ContentAllTabViewModelTest {
|
|||||||
verifyGetContents(type = MainContentAllType.ORIGINAL, page = 0, dayOfWeek = null)
|
verifyGetContents(type = MainContentAllType.ORIGINAL, page = 0, dayOfWeek = null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `외부 선택 요청은 FREE POPULAR 첫 페이지를 dayOfWeek 없이 요청한다`() {
|
||||||
|
stubGetContents(
|
||||||
|
type = MainContentAllType.FREE,
|
||||||
|
sort = ContentSort.POPULAR,
|
||||||
|
response = Single.just(
|
||||||
|
ApiResponse(
|
||||||
|
true,
|
||||||
|
response(
|
||||||
|
type = MainContentAllType.FREE,
|
||||||
|
sort = ContentSort.POPULAR,
|
||||||
|
audios = listOf(audio(30L))
|
||||||
|
),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
viewModel.selectTypeAndSort(MainContentAllType.FREE, ContentSort.POPULAR)
|
||||||
|
|
||||||
|
val state = viewModel.allTabStateLiveData.requireValue() as MainContentAllTabUiState.Content
|
||||||
|
assertEquals(MainContentAllType.FREE, state.selectedType)
|
||||||
|
assertEquals(ContentSort.POPULAR, state.selectedSort)
|
||||||
|
assertEquals(null, state.selectedDayOfWeek)
|
||||||
|
assertEquals(0, state.page)
|
||||||
|
verifyGetContents(
|
||||||
|
type = MainContentAllType.FREE,
|
||||||
|
sort = ContentSort.POPULAR,
|
||||||
|
page = 0,
|
||||||
|
dayOfWeek = null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `외부 선택 요청은 ORIGINAL LATEST 첫 페이지를 dayOfWeek 없이 요청한다`() {
|
||||||
|
stubGetContents(
|
||||||
|
type = MainContentAllType.ORIGINAL,
|
||||||
|
response = Single.just(
|
||||||
|
ApiResponse(
|
||||||
|
true,
|
||||||
|
response(
|
||||||
|
type = MainContentAllType.ORIGINAL,
|
||||||
|
series = listOf(series(31L))
|
||||||
|
),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
viewModel.selectTypeAndSort(MainContentAllType.ORIGINAL, ContentSort.LATEST)
|
||||||
|
|
||||||
|
val state = viewModel.allTabStateLiveData.requireValue() as MainContentAllTabUiState.Content
|
||||||
|
assertEquals(MainContentAllType.ORIGINAL, state.selectedType)
|
||||||
|
assertEquals(ContentSort.LATEST, state.selectedSort)
|
||||||
|
assertEquals(null, state.selectedDayOfWeek)
|
||||||
|
assertEquals(0, state.page)
|
||||||
|
verifyGetContents(
|
||||||
|
type = MainContentAllType.ORIGINAL,
|
||||||
|
sort = ContentSort.LATEST,
|
||||||
|
page = 0,
|
||||||
|
dayOfWeek = null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `SERIES에서 요일 변경은 변경 요일과 page 0으로 요청한다`() {
|
fun `SERIES에서 요일 변경은 변경 요일과 page 0으로 요청한다`() {
|
||||||
stubGetContents(response = Single.just(ApiResponse(true, response(), null)))
|
stubGetContents(response = Single.just(ApiResponse(true, response(), null)))
|
||||||
|
|||||||
Reference in New Issue
Block a user