✨ Show movie release type in generated HTML
[rhynodge.git] / src / test / kotlin / net / pterodactylus / rhynodge / filters / webpages / savoy / MovieStateTest.kt
index 54a6dde..857bd03 100644 (file)
@@ -19,9 +19,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", "").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), "", "")) }
                        ), emptySet()
                )
                assertThat(movieState.output(Reaction("", null, null, null)).summary(), containsString("2024-02-11"))
@@ -108,6 +108,24 @@ class MovieStateTest {
                )
        }
 
+       @Test
+       fun `html output contains the correct release type for movies`() {
+               val movieState = MovieState(
+                       setOf(
+                               movie("Movie 1", "https://cdn.premiumkino.de/movie/3047/81c49774d7828a898ae1d525ffd135af_w300.jpg", "20240212-1845" to "2D OV", "20240213-1330" to "2D", "20240214-1815" to "2D OmeU"),
+                       ), setOf()
+               )
+               val output = movieState.output(Reaction("", null, null, null))
+               val html = output.text("text/html")
+               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(
+                               "Movie 1 - 18:45 - 2D OV", "Movie 1 - 13:30 - 2D", "Movie 1 - 18:15 - 2D OmeU"
+                       )
+               )
+       }
+
 }
 
 private fun dateTime(dateTimeString: String) = LocalDateTime.of(
@@ -119,5 +137,9 @@ private fun dateTime(dateTimeString: String) = LocalDateTime.of(
 )
 
 private fun movie(name: String, imageUrl: String, vararg times: String) = Movie(name, imageUrl).apply {
-       times.map(::dateTime).map { Performance(it, "https://link/$it") }.forEach(this::addPerformance)
+       times.map(::dateTime).map { Performance(it, "", "https://link/$it") }.forEach(this::addPerformance)
+}
+
+private fun movie(name: String, imageUrl: String, vararg timesAndTypes: Pair<String, String>) = Movie(name, imageUrl).apply {
+       timesAndTypes.map { Performance(it.first.let(::dateTime), it.second, "https://link/${it.first}") }.forEach(this::addPerformance)
 }