Skip to content

Commit

Permalink
fix: don't append volume to series title if equals to 1
Browse files Browse the repository at this point in the history
closes gotson#347
  • Loading branch information
gotson committed Oct 29, 2020
1 parent ef780c3 commit 1cb9ae6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ 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)" } ?: "")
series + (comicInfo.volume?.let { if (it != 1) " ($it)" else "" } ?: "")
}

return SeriesMetadataPatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,22 @@ class ComicInfoProviderTest {
}
}

@Test
fun `given comicInfo with volume as 1 when getting series metadata then metadata title omits volume`() {
val comicInfo = ComicInfo().apply {
series = "series"
volume = 1
}

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

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

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

@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 1cb9ae6

Please sign in to comment.