Skip to content

Commit

Permalink
feat: append volume to series name
Browse files Browse the repository at this point in the history
closes #343, closes #132
  • Loading branch information
gotson committed Oct 22, 2020
1 parent eb10a12 commit 2567796
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ class ComicInfoProvider(
}

val genres = comicInfo.genre?.split(',')?.mapNotNull { it.trim().ifBlank { null } }
val series = comicInfo.series?.ifBlank { null }?.let { series ->
series + (comicInfo.volume?.let { " ($it)" } ?: "")
}

return SeriesMetadataPatch(
title = comicInfo.series?.ifBlank { null },
titleSort = comicInfo.series?.ifBlank { null },
title = series,
titleSort = series,
status = null,
summary = null,
readingDirection = readingDirection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,22 @@ class ComicInfoProviderTest {
}
}

@Test
fun `given comicInfo with volume when getting series metadata then metadata patch is valid`() {
val comicInfo = ComicInfo().apply {
series = "series"
volume = 2020
}

every { mockMapper.readValue(any<ByteArray>(), ComicInfo::class.java) } returns comicInfo

val patch = comicInfoProvider.getSeriesMetadataFromBook(book, media)!!

with(patch) {
assertThat(title).isEqualTo("series (2020)")
}
}

@Test
fun `given comicInfo with incorrect values when getting series metadata then metadata patch is valid`() {
val comicInfo = ComicInfo().apply {
Expand Down

0 comments on commit 2567796

Please sign in to comment.