From d261ecdc2caba6e671d963adcfc4c3097be80726 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 7 May 2024 10:40:40 +0100 Subject: [PATCH] Fixed tests --- .../ui/component/ComponentGroupTests.scala | 10 ++--- .../ui/window/WindowModelTests.scala | 38 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/roguelike-starterkit/src/test/scala/roguelikestarterkit/ui/component/ComponentGroupTests.scala b/roguelike-starterkit/src/test/scala/roguelikestarterkit/ui/component/ComponentGroupTests.scala index cfc6197a..afc6b128 100644 --- a/roguelike-starterkit/src/test/scala/roguelikestarterkit/ui/component/ComponentGroupTests.scala +++ b/roguelike-starterkit/src/test/scala/roguelikestarterkit/ui/component/ComponentGroupTests.scala @@ -8,16 +8,16 @@ import roguelikestarterkit.ui.component.ComponentLayout.Horizontal class ComponentGroupTests extends munit.FunSuite { - given Component[String] = new Component[String] { + given Component[String, Unit] = new Component[String, Unit] { def bounds(model: String): Bounds = Bounds(0, 0, model.length, 1) - def updateModel[Unit]( + def updateModel( context: UiContext[Unit], model: String ): GlobalEvent => Outcome[String] = _ => Outcome(model) - def present[Unit]( + def present( context: UiContext[Unit], model: String ): Outcome[ComponentFragment] = @@ -31,8 +31,8 @@ class ComponentGroupTests extends munit.FunSuite { } test("reflow should reapply the layout to all existing components") { - val component1 = ComponentEntry(Coords(0, 0), "abc", summon[Component[String]]) - val component2 = ComponentEntry(Coords(10, 10), "def", summon[Component[String]]) + val component1 = ComponentEntry(Coords(0, 0), "abc", summon[Component[String, Unit]]) + val component2 = ComponentEntry(Coords(10, 10), "def", summon[Component[String, Unit]]) val group = ComponentGroup( Bounds(0, 0, 100, 100), BoundsType.Fixed, diff --git a/roguelike-starterkit/src/test/scala/roguelikestarterkit/ui/window/WindowModelTests.scala b/roguelike-starterkit/src/test/scala/roguelikestarterkit/ui/window/WindowModelTests.scala index 5281fa57..ecaba3b4 100644 --- a/roguelike-starterkit/src/test/scala/roguelikestarterkit/ui/window/WindowModelTests.scala +++ b/roguelike-starterkit/src/test/scala/roguelikestarterkit/ui/window/WindowModelTests.scala @@ -53,8 +53,8 @@ class WindowModelTests extends munit.FunSuite: FontKey("test") ) - val component = ComponentEntry(Coords(0, 0), "abc", summon[Component[String]]) - val group = ComponentGroup( + val component = ComponentEntry[String, Unit](Coords(0, 0), "abc", summon[Component[String, Unit]]) + val group = ComponentGroup[Unit]( Bounds(0, 0, 100, 100), BoundsType.Fixed, ComponentLayout.Horizontal(Padding(5), Overflow.Wrap), @@ -62,7 +62,7 @@ class WindowModelTests extends munit.FunSuite: ) test("model cascades bounds changes to component group - BoundsType.Fixed") { - val model: WindowModel[ComponentGroup, Unit] = + val model: WindowModel[ComponentGroup[Unit], Unit] = WindowModel( WindowId("test"), charSheet, @@ -73,7 +73,7 @@ class WindowModelTests extends munit.FunSuite: } test("model cascades bounds changes to component group - BoundsType.Inherit") { - val model: WindowModel[ComponentGroup, Unit] = + val model: WindowModel[ComponentGroup[Unit], Unit] = WindowModel( WindowId("test"), charSheet, @@ -84,7 +84,7 @@ class WindowModelTests extends munit.FunSuite: } test("model cascades bounds changes to component group - BoundsType.Relative") { - val model: WindowModel[ComponentGroup, Unit] = + val model: WindowModel[ComponentGroup[Unit], Unit] = WindowModel( WindowId("test"), charSheet, @@ -95,7 +95,7 @@ class WindowModelTests extends munit.FunSuite: } test("model cascades bounds changes to component group - BoundsType.Relative 100%") { - val model: WindowModel[ComponentGroup, Unit] = + val model: WindowModel[ComponentGroup[Unit], Unit] = WindowModel( WindowId("test"), charSheet, @@ -106,7 +106,7 @@ class WindowModelTests extends munit.FunSuite: } test("model cascades bounds changes to component group - BoundsType.RelativePosition") { - val model: WindowModel[ComponentGroup, Unit] = + val model: WindowModel[ComponentGroup[Unit], Unit] = WindowModel( WindowId("test"), charSheet, @@ -117,7 +117,7 @@ class WindowModelTests extends munit.FunSuite: } test("model cascades bounds changes to component group - BoundsType.RelativeSize") { - val model: WindowModel[ComponentGroup, Unit] = + val model: WindowModel[ComponentGroup[Unit], Unit] = WindowModel( WindowId("test"), charSheet, @@ -128,7 +128,7 @@ class WindowModelTests extends munit.FunSuite: } test("model cascades bounds changes to component group - BoundsType.Offset") { - val model: WindowModel[ComponentGroup, Unit] = + val model: WindowModel[ComponentGroup[Unit], Unit] = WindowModel( WindowId("test"), charSheet, @@ -139,7 +139,7 @@ class WindowModelTests extends munit.FunSuite: } test("model cascades bounds changes to component group - BoundsType.OffsetPosition") { - val model: WindowModel[ComponentGroup, Unit] = + val model: WindowModel[ComponentGroup[Unit], Unit] = WindowModel( WindowId("test"), charSheet, @@ -150,7 +150,7 @@ class WindowModelTests extends munit.FunSuite: } test("model cascades bounds changes to component group - BoundsType.OffsetSize") { - val model: WindowModel[ComponentGroup, Unit] = + val model: WindowModel[ComponentGroup[Unit], Unit] = WindowModel( WindowId("test"), charSheet, @@ -173,7 +173,7 @@ class WindowModelTests extends munit.FunSuite: .add(Bounds(0, 0, 0, 0)) ) - val model: WindowModel[ComponentGroup, Unit] = + val model: WindowModel[ComponentGroup[Unit], Unit] = WindowModel( WindowId("test"), charSheet, @@ -188,7 +188,7 @@ class WindowModelTests extends munit.FunSuite: fail("No sub components found") case Some(value) => - val cg = value.model.asInstanceOf[ComponentGroup] + val cg = value.model.asInstanceOf[ComponentGroup[Unit]] // top comp group cascades to next level. assertEquals(cg.bounds, Bounds(3, 5, 36, 34)) @@ -205,16 +205,16 @@ class WindowModelTests extends munit.FunSuite: } - given Component[String] = new Component[String] { + given Component[String, Unit] = new Component[String, Unit] { def bounds(model: String): Bounds = Bounds(0, 0, model.length, 1) - def updateModel[Unit]( + def updateModel( context: UiContext[Unit], model: String ): GlobalEvent => Outcome[String] = _ => Outcome(model) - def present[Unit]( + def present( context: UiContext[Unit], model: String ): Outcome[ComponentFragment] = @@ -227,16 +227,16 @@ class WindowModelTests extends munit.FunSuite: model } - given Component[Bounds] = new Component[Bounds] { + given Component[Bounds, Unit] = new Component[Bounds, Unit] { def bounds(model: Bounds): Bounds = model - def updateModel[Unit]( + def updateModel( context: UiContext[Unit], model: Bounds ): GlobalEvent => Outcome[Bounds] = _ => Outcome(model) - def present[Unit]( + def present( context: UiContext[Unit], model: Bounds ): Outcome[ComponentFragment] =