fix: don't append volume to series title if equals to 1

closes #347
This commit is contained in:
Gauthier Roebroeck 2020-10-29 19:53:56 +08:00
parent ef780c31d6
commit 1cb9ae6aad
2 changed files with 17 additions and 1 deletions

View file

@ -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(

View file

@ -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 {