♻️ Remove “addPerformance” method
[rhynodge.git] / src / test / kotlin / net / pterodactylus / rhynodge / filters / webpages / savoy / MovieStateTest.kt
index 77ff2d3..bb2fa9b 100644 (file)
@@ -20,9 +20,9 @@ class MovieStateTest {
        fun `summary contains date of earliest movie`() {
                val movieState = MovieState(
                        setOf(
-                               Movie("1", "", "").apply { addPerformance(Performance(LocalDateTime.of(2024, 2, 12, 18, 45), "", "")) },
-                               Movie("2", "", "").apply { addPerformance(Performance(LocalDateTime.of(2024, 3, 12, 15, 30), "", "")) },
-                               Movie("3", "", "").apply { addPerformance(Performance(LocalDateTime.of(2024, 2, 11, 21, 15), "", "")) }
+                               Movie("1", "", "", listOf(Performance(LocalDateTime.of(2024, 2, 12, 18, 45), "", ""))),
+                               Movie("2", "", "", listOf(Performance(LocalDateTime.of(2024, 3, 12, 15, 30), "", ""))),
+                               Movie("3", "", "", listOf(Performance(LocalDateTime.of(2024, 2, 11, 21, 15), "", "")))
                        ), emptySet()
                )
                assertThat(movieState.output(Reaction("", null, null, null)).summary(), containsString("2024-02-11"))
@@ -129,7 +129,7 @@ class MovieStateTest {
                val document = Jsoup.parse(html)
                assertThat(
                        document.select("section.daily-programmes li.performance")
-                               .map { performance -> listOf(".name", ".time", ".type").map { performance.select(it).text() }.joinToString(" - ")}, contains(
+                               .map { performance -> listOf(".name", ".time", ".type").map { performance.select(it).text() }.joinToString(" - ") }, contains(
                                "Movie 1 - 18:45 - 2D OV", "Movie 1 - 13:30 - 2D", "Movie 1 - 18:15 - 2D OmeU"
                        )
                )
@@ -145,10 +145,11 @@ private fun dateTime(dateTimeString: String) = LocalDateTime.of(
        dateTimeString.substring(11..12).toInt(),
 )
 
-private fun movie(name: String, imageUrl: String, description: String = "", vararg times: String) = Movie(name, imageUrl, description).apply {
-       times.map(::dateTime).map { Performance(it, "", "https://link/$it") }.forEach(this::addPerformance)
-}
+private fun movie(name: String, imageUrl: String, description: String = "", vararg times: String) =
+       times.map(::dateTime)
+               .map { Performance(it, "", "https://link/$it") }
+               .let { Movie(name, imageUrl, description, it) }
 
-private fun movie(name: String, imageUrl: String, description: String = "", vararg timesAndTypes: Pair<String, String>) = Movie(name, imageUrl, description).apply {
-       timesAndTypes.map { Performance(it.first.let(::dateTime), it.second, "https://link/${it.first}") }.forEach(this::addPerformance)
-}
+private fun movie(name: String, imageUrl: String, description: String = "", vararg timesAndTypes: Pair<String, String>) =
+       timesAndTypes.map { Performance(it.first.let(::dateTime), it.second, "https://link/${it.first}") }
+               .let { Movie(name, imageUrl, description, it) }