1 package net.pterodactylus.rhynodge.filters.webpages.epicgames
3 import net.pterodactylus.rhynodge.Reaction
4 import org.hamcrest.MatcherAssert.assertThat
5 import org.hamcrest.Matchers.contains
6 import org.hamcrest.Matchers.equalTo
9 import java.time.Instant
10 import java.time.ZoneOffset
12 class FreeGamesStateTest {
15 fun `can create free games state`() {
16 FreeGamesState(emptySet())
20 fun `state lists all games in text output`() {
21 val output = state.output(Reaction("", null, null, null)).text("text/plain")
25 "Good Game: 1970-01-01 00:16:40 - 1970-01-01 00:33:20 (https://good.game/image.jpg)",
26 "Best Game: 1970-01-01 00:33:20 - 1970-01-01 00:50:00 (https://best.game/image.webp)",
27 "Better Game: 1970-01-01 00:50:00 - 1970-01-01 01:06:40 (https://better.game/image.png)",
34 fun `state lists all games in HTML output`() {
35 val output = state.output(Reaction("", null, null, null)).text("text/html")
36 val parsedOutput = Jsoup.parse(output)
38 parsedOutput.select(".game").map {
40 it.select(".game-title").text(),
41 it.select(".game-image img").attr("src"),
42 it.select(".game-start").text(),
43 it.select(".game-end").text()
46 "Good Game, https://good.game/image.jpg, 1970-01-01 00:16:40, 1970-01-01 00:33:20",
47 "Best Game, https://best.game/image.webp, 1970-01-01 00:33:20, 1970-01-01 00:50:00",
48 "Better Game, https://better.game/image.png, 1970-01-01 00:50:00, 1970-01-01 01:06:40",
55 private val freeGames = setOf(
56 FreeGame("Good Game", "https://good.game/image.jpg", Instant.ofEpochSecond(1000), Instant.ofEpochSecond(2000)),
57 FreeGame("Better Game", "https://better.game/image.png", Instant.ofEpochSecond(3000), Instant.ofEpochSecond(4000)),
58 FreeGame("Best Game", "https://best.game/image.webp", Instant.ofEpochSecond(2000), Instant.ofEpochSecond(3000)),
60 private val state = FreeGamesState(freeGames, timezone = ZoneOffset.UTC)