Skip to content

Commit

Permalink
Cleaner test for RedirectOwner
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Oct 9, 2024
1 parent 63d338d commit f6aeaf3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions modules/game/src/test/EventTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,9 @@ class EventTest extends munit.ScalaCheckSuite:

test("RedirectOwner anti regression"):
// We use Event.Castling as a cookie for this test because We don't have an Arbitrary instance for JsObject yet
forAll: (color: Color, gameId: GameId, playerId: GamePlayerId, cookie: Option[Event.Castling]) =>
val id = GameFullId(gameId, playerId)
forAll: (color: Color, id: GameFullId, cookie: Option[Event.Castling]) =>
val event = Event.RedirectOwner(color, id, cookie.map(_.data.asInstanceOf[JsObject]))
assertEquals(event.data.str("id"), s"${id.value}".some)
assertEquals(event.data.str("url"), s"/${id.value}".some)
assertEquals(event.data.str("id"), id.value.some)
assertEquals(event.data.str("url"), s"/$id".some)
assertEquals(event.data.obj("cookie"), cookie.map(_.data))
assertEquals(event.typ, "redirect")

0 comments on commit f6aeaf3

Please sign in to comment.