X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Frhynodge%2Ffilters%2Fwebpages%2Fsavoy%2FMovieStateTest.kt;h=bb2fa9bd91b886ebc63633dee461934029af55f9;hb=344c25bffd290586dbbb3f0d2b67e36308d6cd57;hp=77ff2d3e5c91f1eee9b2084b3ca5ce3ca9fe9459;hpb=894ec391181f30ea4d315c2137492ef57ae8fe07;p=rhynodge.git diff --git a/src/test/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/MovieStateTest.kt b/src/test/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/MovieStateTest.kt index 77ff2d3..bb2fa9b 100644 --- a/src/test/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/MovieStateTest.kt +++ b/src/test/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/MovieStateTest.kt @@ -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) = 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) = + timesAndTypes.map { Performance(it.first.let(::dateTime), it.second, "https://link/${it.first}") } + .let { Movie(name, imageUrl, description, it) }