Yokan / rebuild
Course 1 8624561

LibraryUpdateScopeTest.kt

composeApp/src/commonTest/kotlin/eu/friedcutlet/yokan/ui/screens/library/LibraryUpdateScopeTest.kt

test / fixture41 lines
1package eu.friedcutlet.yokan.ui.screens.library23import eu.friedcutlet.yokan.data.LibraryIndex4import eu.friedcutlet.yokan.database.*5import eu.friedcutlet.yokan.domain.*6import kotlin.test.*78class LibraryUpdateScopeTest {9    private fun title(id: Long, categories: List<Long> = emptyList(), tags: List<String> = emptyList()) = Manga(id = id,10        name = "Title $id", link = "/$id", description = "", status = Status.Ongoing, itemType = ItemType.Manga,11        favorite = true, source = "Source", lang = "en", dateAddedMillis = 0, lastUpdateMillis = 0, categories = categories, genres = tags)12    private val titles = listOf(title(1, listOf(10), listOf("One")), title(2, listOf(10, 20), listOf("One", "Two")), title(3))13    private val categories = listOf(Category(10, "One", ItemType.Manga, 0), Category(20, "Two", ItemType.Manga, 1))14    private fun content(group: DbLibraryGrouping = DbLibraryGrouping.Categories, search: String = "") = libraryContent(titles, categories,15        LibraryIndex.Empty, LibraryQuery(search, LibraryFilterTypes(0, 0, 0, 0, 0, 0), DbSortLibraryManga(), false, grouping = group))1617    @Test fun globalAndAllRemainGlobalButUnloadedOrStaleGroupsCannotExpandToGlobal() {18        assertNull(libraryUpdateTitleIds(null, 10, DbGroupUpdateMode.Global, LibraryIndex.Empty))19        assertEquals(emptySet(), libraryUpdateTitleIds(null, 10, DbGroupUpdateMode.CurrentGroup, LibraryIndex.Empty))20        assertEquals(emptySet(), libraryUpdateTitleIds(content(), 999, DbGroupUpdateMode.CurrentGroup, LibraryIndex.Empty))21        assertNull(libraryUpdateTitleIds(content(), null, DbGroupUpdateMode.CurrentGroup, LibraryIndex.Empty))22    }2324    @Test fun categoryScopeUsesRawMembershipInsteadOfSearchAndRowMatches() {25        val hidden = content(search = "not found")26        assertTrue(hidden.items(10).isEmpty())27        assertEquals(setOf(1L, 2L), libraryUpdateTitleIds(hidden, 10, DbGroupUpdateMode.CurrentGroup, LibraryIndex.Empty))28        assertEquals(setOf(3L), libraryUpdateTitleIds(hidden, UncategorizedCategoryId, DbGroupUpdateMode.CurrentGroup, LibraryIndex.Empty))29    }3031    @Test fun automaticGroupsUseStableRawMembershipAndDeduplicateMultiTagEntries() {32        val hidden = content(DbLibraryGrouping.Tags, search = "not found")33        val id = hidden.tabs.single { it.name == "One" }.id34        assertEquals(setOf(1L, 2L), libraryUpdateTitleIds(hidden, id, DbGroupUpdateMode.CurrentGroup, LibraryIndex.Empty))35    }3637    @Test fun ungroupedExceptionUsesTheWholeLibrary() {38        assertNull(libraryUpdateTitleIds(content(DbLibraryGrouping.Ungrouped), null, DbGroupUpdateMode.CurrentExceptUngrouped, LibraryIndex.Empty))39        assertEquals(setOf(2L), libraryUpdateTitleIds(content(), 20, DbGroupUpdateMode.CurrentExceptUngrouped, LibraryIndex.Empty))40    }41}42

Search chapters, reference and source filenames.