|
|
|
@ -3,6 +3,7 @@ package org.koitharu.kotatsu.parsers
|
|
|
|
import kotlinx.coroutines.test.runTest
|
|
|
|
import kotlinx.coroutines.test.runTest
|
|
|
|
import okhttp3.HttpUrl
|
|
|
|
import okhttp3.HttpUrl
|
|
|
|
import org.junit.jupiter.api.Disabled
|
|
|
|
import org.junit.jupiter.api.Disabled
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test
|
|
|
|
import org.junit.jupiter.api.extension.ExtendWith
|
|
|
|
import org.junit.jupiter.api.extension.ExtendWith
|
|
|
|
import org.junit.jupiter.params.ParameterizedTest
|
|
|
|
import org.junit.jupiter.params.ParameterizedTest
|
|
|
|
import org.koitharu.kotatsu.parsers.model.Manga
|
|
|
|
import org.koitharu.kotatsu.parsers.model.Manga
|
|
|
|
@ -10,10 +11,7 @@ import org.koitharu.kotatsu.parsers.model.MangaSource
|
|
|
|
import org.koitharu.kotatsu.parsers.model.SortOrder
|
|
|
|
import org.koitharu.kotatsu.parsers.model.SortOrder
|
|
|
|
import org.koitharu.kotatsu.parsers.util.medianOrNull
|
|
|
|
import org.koitharu.kotatsu.parsers.util.medianOrNull
|
|
|
|
import org.koitharu.kotatsu.parsers.util.mimeType
|
|
|
|
import org.koitharu.kotatsu.parsers.util.mimeType
|
|
|
|
import org.koitharu.kotatsu.test_util.isDistinct
|
|
|
|
import org.koitharu.kotatsu.test_util.*
|
|
|
|
import org.koitharu.kotatsu.test_util.isDistinctBy
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.test_util.isUrlAbsolute
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.test_util.maxDuplicates
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ExtendWith(AuthCheckExtension::class)
|
|
|
|
@ExtendWith(AuthCheckExtension::class)
|
|
|
|
@ -21,6 +19,24 @@ internal class MangaParserTest {
|
|
|
|
|
|
|
|
|
|
|
|
private val context = MangaLoaderContextMock()
|
|
|
|
private val context = MangaLoaderContextMock()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun singleTest() = runTest {
|
|
|
|
|
|
|
|
val manga = mangaOf(MangaSource.MANGALIB, "https://mangalib.me/dorohedoro")
|
|
|
|
|
|
|
|
val parser = manga.source.newParser(context)
|
|
|
|
|
|
|
|
val details = parser.getDetails(manga)
|
|
|
|
|
|
|
|
val chapter = details.chapters!!.first()
|
|
|
|
|
|
|
|
val pages = parser.getPages(chapter)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert(pages.isNotEmpty())
|
|
|
|
|
|
|
|
assert(pages.isDistinctBy { it.id })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val page = pages.medianOrNull() ?: error("No page")
|
|
|
|
|
|
|
|
val pageUrl = parser.getPageUrl(page)
|
|
|
|
|
|
|
|
assert(pageUrl.isNotEmpty())
|
|
|
|
|
|
|
|
assert(pageUrl.isUrlAbsolute())
|
|
|
|
|
|
|
|
checkImageRequest(pageUrl, page.referer)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest(name = "{index}|list|{0}")
|
|
|
|
@ParameterizedTest(name = "{index}|list|{0}")
|
|
|
|
@MangaSources
|
|
|
|
@MangaSources
|
|
|
|
fun list(source: MangaSource) = runTest {
|
|
|
|
fun list(source: MangaSource) = runTest {
|
|
|
|
|