This commit is contained in:
Mitchell Syer
2022-10-22 08:08:14 -04:00
committed by GitHub
parent 3bef07eeab
commit a3c366c360
54 changed files with 159 additions and 109 deletions

View File

@@ -31,12 +31,14 @@ class CategoryMangaTest : ApplicationTest() {
createChapters(mangaId, 10, true)
assertEquals(1, CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID).size, "Default category should have one member")
assertEquals(
0, CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID)[0].unreadCount,
0,
CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID)[0].unreadCount,
"Manga should not have any unread chapters"
)
createChapters(mangaId, 10, false)
assertEquals(
10, CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID)[0].unreadCount,
10,
CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID)[0].unreadCount,
"Manga should have unread chapters"
)
@@ -48,15 +50,18 @@ class CategoryMangaTest : ApplicationTest() {
)
CategoryManga.addMangaToCategory(mangaId, categoryId)
assertEquals(
1, CategoryManga.getCategoryMangaList(categoryId).size,
1,
CategoryManga.getCategoryMangaList(categoryId).size,
"Manga should been moved"
)
assertEquals(
10, CategoryManga.getCategoryMangaList(categoryId)[0].unreadCount,
10,
CategoryManga.getCategoryMangaList(categoryId)[0].unreadCount,
"Manga should keep it's unread count in moved category"
)
assertEquals(
0, CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID).size,
0,
CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID).size,
"Manga shouldn't be member of default category after moving"
)
}

View File

@@ -36,17 +36,20 @@ class MangaTest : ApplicationTest() {
"Manga meta should still only have one pair"
)
assertEquals(
"newValue", Manga.getMangaMetaMap(metaManga)["test"],
"newValue",
Manga.getMangaMetaMap(metaManga)["test"],
"Manga meta with key 'test' should use the value `newValue`"
)
Manga.modifyMangaMeta(metaManga, "test2", "value2")
assertEquals(
2, Manga.getMangaMetaMap(metaManga).size,
2,
Manga.getMangaMetaMap(metaManga).size,
"Manga Meta should have an additional pair"
)
assertEquals(
"value2", Manga.getMangaMetaMap(metaManga)["test2"],
"value2",
Manga.getMangaMetaMap(metaManga)["test2"],
"Manga Meta for key 'test2' should be 'value2'"
)
}

View File

@@ -87,7 +87,8 @@ class FilterListTest : ApplicationTest() {
val filterList = getFilterList(source.id, false)
assertEquals(
0, filterList.size
0,
filterList.size
)
}
@@ -111,7 +112,7 @@ class FilterListTest : ApplicationTest() {
listOf(
TestCheckBox("Write Tests"),
TestCheckBox("Write More Tests"),
TestCheckBox("Write Even More Tests"),
TestCheckBox("Write Even More Tests")
)
),
Sort(
@@ -160,7 +161,7 @@ class FilterListTest : ApplicationTest() {
listOf(
FilterObject("CheckBox", (source.mFilterList[6].state as List<Filter<*>>)[0]),
FilterObject("CheckBox", (source.mFilterList[6].state as List<Filter<*>>)[1]),
FilterObject("CheckBox", (source.mFilterList[6].state as List<Filter<*>>)[2]),
FilterObject("CheckBox", (source.mFilterList[6].state as List<Filter<*>>)[2])
)
)
)

View File

@@ -31,7 +31,7 @@ class PaginatedListTest : ApplicationTest() {
assertEquals(
PaginatedList(listIndicesOf(0, PaginationFactor - 1), false),
paginated,
paginated
)
}
@@ -43,14 +43,14 @@ class PaginatedListTest : ApplicationTest() {
assertEquals(
PaginatedList(listIndicesOf(0, PaginationFactor), true),
firstPage,
firstPage
)
val secondPage = paginatedFrom(1, lister = masterLister)
assertEquals(
PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2 - 1), false),
secondPage,
secondPage
)
}
@@ -62,14 +62,14 @@ class PaginatedListTest : ApplicationTest() {
assertEquals(
PaginatedList(listIndicesOf(0, PaginationFactor), true),
firstPage,
firstPage
)
val secondPage = paginatedFrom(1, lister = masterLister)
assertEquals(
PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2), false),
secondPage,
secondPage
)
}
@@ -81,21 +81,21 @@ class PaginatedListTest : ApplicationTest() {
assertEquals(
PaginatedList(listIndicesOf(0, PaginationFactor), true),
firstPage,
firstPage
)
val secondPage = paginatedFrom(1, lister = masterLister)
assertEquals(
PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2), true),
secondPage,
secondPage
)
val thirdPage = paginatedFrom(2, lister = masterLister)
assertEquals(
PaginatedList(listIndicesOf(PaginationFactor * 2, PaginationFactor * 2 + 1), false),
thirdPage,
thirdPage
)
}

View File

@@ -76,7 +76,7 @@ open class ApplicationTest {
applicationDirs.extensionsRoot + "/icon",
applicationDirs.thumbnailsRoot,
applicationDirs.mangaDownloadsRoot,
applicationDirs.localMangaRoot,
applicationDirs.localMangaRoot
).forEach {
File(it).mkdirs()
}

View File

@@ -23,7 +23,9 @@ fun setLoggingEnabled(enabled: Boolean = true) {
val logger = (KotlinLogging.logger(Logger.ROOT_LOGGER_NAME).underlyingLogger as ch.qos.logback.classic.Logger)
logger.level = if (enabled) {
Level.DEBUG
} else Level.ERROR
} else {
Level.ERROR
}
}
const val BASE_PATH = "build/tmp/TestDesk"